예제 #1
0
파일: airtest.c 프로젝트: wtanaka/airhook
void print_status(void) {
	const char * const name = strtok(NULL,"\n");
	if (NULL != name) {
		const int number = atoi(name);
		struct airhook_outgoing_status status;
		if (0 == number || outgoing_count < number) {
			fprintf(stderr,"%s: invalid message\n",name);
			return;
		}

		status = airhook_outgoing_status(outgoing[number - 1]);
		printf("data: %.*s\n",
			status.data.end - status.data.begin,
			status.data.begin);
		printf("state: %s\n",state_name(status.state));
		printf("transmit_count: %lu\n",status.transmit_count);
		printf("last_change: %s\n",time_name(status.last_change));
	} else {
		struct airhook_status status = airhook_status(&socket);
		if (status.session) 
			printf("session: %08lx\n",status.session);
		if (status.remote_session) 
			printf("session: %08lx\n",status.remote_session);
		printf("state: %s\n",state_name(status.state));
		printf("remote_state: %s\n",state_name(status.remote_state));
		printf("last_transmit: %s\n",time_name(status.last_transmit));
		printf("next_transmit: %s\n",time_name(status.next_transmit));
		printf("last_response: %s\n",time_name(status.last_response));
	}
}
예제 #2
0
void
rust_sched_loop::transition(rust_task *task,
                             rust_task_state src, rust_task_state dst,
                             rust_cond *cond, const char* cond_name) {
    scoped_lock with(lock);
    DLOG(this, task,
         "task %s " PTR " state change '%s' -> '%s' while in '%s'",
         name, (uintptr_t)this, state_name(src), state_name(dst),
         state_name(task->get_state()));
    assert(task->get_state() == src);
    rust_task_list *src_list = state_list(src);
    if (src_list) {
        src_list->remove(task);
    }
    rust_task_list *dst_list = state_list(dst);
    if (dst_list) {
        dst_list->append(task);
    }
    if (dst == task_state_dead) {
        assert(dead_task == NULL);
        dead_task = task;
    }
    task->set_state(dst, cond, cond_name);

    // If the entire runtime is failing, newborn tasks must be doomed.
    if (src == task_state_newborn && killed) {
        task->kill_inner();
    }

    pump_loop();
}
예제 #3
0
파일: dbusproxy.c 프로젝트: kimmoli/dsme
DSME_HANDLER(DSM_MSGTYPE_STATE_CHANGE_IND, server, msg)
{
    if (state_replies) {
        // there are yet unsent replies to state queries; sent the first one
        GSList* first_node = state_replies;
        DsmeDbusMessage* first_reply = (DsmeDbusMessage*)(first_node->data);
        dsme_dbus_message_append_string(first_reply, state_name(msg->state));
        dsme_dbus_signal_emit(first_reply); // deletes the reply
        first_node->data = 0;
        state_replies = g_slist_delete_link(state_replies, first_node);
    } else {
        // this is a broadcast state change
        if (msg->state == DSME_STATE_SHUTDOWN ||
            msg->state == DSME_STATE_ACTDEAD  ||
            msg->state == DSME_STATE_REBOOT)
        {
            emit_dsme_dbus_signal(dsme_shutdown_ind);
        }

        DsmeDbusMessage* sig = dsme_dbus_signal_new(sig_path,
                                                    sig_interface,
                                                    dsme_state_change_ind);
        dsme_dbus_message_append_string(sig, state_name(msg->state));
        dsme_dbus_signal_emit(sig);
    }
}
예제 #4
0
void
dcethread__change_state(dcethread* thread, int state)
{
    DCETHREAD_TRACE("Thread %p: state transition %s -> %s",
		thread,
		state_name(thread->state),
		state_name(state));
    thread->state = state;
    pthread_cond_broadcast((pthread_cond_t*) &thread->state_change);
}
예제 #5
0
파일: dslm.c 프로젝트: BinVul/linux2.6.32
static void measure(int fd)
{
    time_t start_time;
    int last_state;
    time_t last_time;
    int curr_state;
    time_t curr_time = 0;
    time_t time_diff;
    time_t active_time = 0;
    time_t sleep_time = 0;
    time_t unknown_time = 0;
    time_t total_time = 0;
    int changes = 0;
    float tmp;

    printf("Starting measurements\n");

    last_state = check_powermode(fd);
    start_time = last_time = time(0);
    printf("  System is in state %s\n\n", state_name(last_state));

    while(!endit) {
	sleep(1);
	curr_state = check_powermode(fd);

	if (curr_state != last_state || endit) {
	    changes++;
	    curr_time = time(0);
	    time_diff = curr_time - last_time;

	    if (last_state == 1) active_time += time_diff;
	    else if (last_state == 0) sleep_time += time_diff;
	    else unknown_time += time_diff;

	    last_state = curr_state;
	    last_time = curr_time;

	    printf("%s: State-change to %s\n", myctime(curr_time),
		   state_name(curr_state));
	}
    }
    changes--; /* Compensate for SIGINT */

    total_time = time(0) - start_time;
    printf("\nTotal running time:  %lus\n", curr_time - start_time);
    printf(" State changed %d times\n", changes);

    tmp = (float)sleep_time / (float)total_time * 100;
    printf(" Time in sleep state:   %lus (%.2f%%)\n", sleep_time, tmp);
    tmp = (float)active_time / (float)total_time * 100;
    printf(" Time in active state:  %lus (%.2f%%)\n", active_time, tmp);
    tmp = (float)unknown_time / (float)total_time * 100;
    printf(" Time in unknown state: %lus (%.2f%%)\n", unknown_time, tmp);
}
static inline void
trace_state_change (const char *transition, MonoThreadInfo *info, int cur_raw_state, int next_state, int suspend_count_delta)
{
	check_thread_state (info);
	THREADS_STATE_MACHINE_DEBUG ("[%s][%p] %s -> %s (%d -> %d)\n",
		transition,
		mono_thread_info_get_tid (info),
		state_name (get_thread_state (cur_raw_state)),
		state_name (next_state),
		get_thread_suspend_count (cur_raw_state),
		get_thread_suspend_count (cur_raw_state) + suspend_count_delta);
}
예제 #7
0
		void
		ensure_valid_state(
			state_t expected_state ) const
		{
			if( m_state != expected_state )
			{
				std::cerr << "expected and actual states mismatch! "
							"current state: "
						<< state_name( m_state ) << " expected state: "
						<< state_name( expected_state );

				std::abort();
			}
		}
예제 #8
0
void machine_t::process_transition_queue()
{
  if(transition_in_progress())
  {
    log_debug("process_transition_queue() is already in progress, returning") ;
    return ; // never do it recursively
  }
  // log_debug("begin processing, states: %s tqueue: %s" , s_states().c_str(), s_transition_queue().c_str()) ;
  transition_start_time = ticker_t(now()) ;
  bool queue_changed = false ;
  for(; not transition_queue.empty(); queue_changed = true, transition_queue.pop_front())
  {
#define state_name(p) (p?p->name():"null")
    event_t *e = transition_queue.front().first ;
    abstract_state_t *new_state = transition_queue.front().second ;
    if (not is_event_registered(e))
    {
      log_error("requested to move destroyed event %p to state '%s'", e, state_name(new_state)) ;
      continue ;
    }
    abstract_state_t *old_state = e->get_state() ;
    log_notice("State transition %d:'%s'->'%s'", e->cookie.value(), state_name(old_state), state_name(new_state)) ;
    if (new_state==old_state)
      log_critical("Event %d: new_state=old_state='%s'", e->cookie.value(), old_state->name()) ;
#undef state_name
    if(old_state)
      old_state->leave(e) ;
    e->set_state(new_state) ;
    if(new_state)
    {
      new_state->enter(e) ;
      e->sort_and_run_actions(new_state->get_action_mask()) ;
    }
    else
    {
      log_notice("Destroying the event %u (event object %p)", e->cookie.value(), e) ;
      unregister_event(e) ;
      delete e ;
    }
  }
  // log_debug("processing done,  states: %s tqueue: %s" , s_states().c_str(), s_transition_queue().c_str()) ;
  transition_start_time = ticker_t(0) ;
  transition_time_adjustment.set(0) ;
  if(queue_changed)
    emit queue_to_be_saved() ;
  if(context_changed)
    send_queue_context() ;
  send_bootup_signal() ;
}
예제 #9
0
static inline void
trace_state_change_with_func (const char *transition, MonoThreadInfo *info, int cur_raw_state, int next_state, int suspend_count_delta, const char *func)
{
	check_thread_state (info);
	THREADS_STATE_MACHINE_DEBUG ("[%s][%p] %s -> %s (%d -> %d) %s\n",
		transition,
		mono_thread_info_get_tid (info),
		state_name (get_thread_state (cur_raw_state)),
		state_name (next_state),
		get_thread_suspend_count (cur_raw_state),
		get_thread_suspend_count (cur_raw_state) + suspend_count_delta,
		func);

	CHECKED_BUILD_THREAD_TRANSITION (transition, info, get_thread_state (cur_raw_state), get_thread_suspend_count (cur_raw_state), next_state, suspend_count_delta);
}
예제 #10
0
static int otg_init(struct isp1301 *isp)
{
	if (!otg_dev)
		return -ENODEV;

	dump_regs(isp, __func__);
	/* some of these values are board-specific... */
	OTG_SYSCON_2_REG |= OTG_EN
		/* for B-device: */
		| SRP_GPDATA		/* 9msec Bdev D+ pulse */
		| SRP_GPDVBUS		/* discharge after VBUS pulse */
		// | (3 << 24)		/* 2msec VBUS pulse */
		/* for A-device: */
		| (0 << 20)		/* 200ms nominal A_WAIT_VRISE timer */
		| SRP_DPW		/* detect 167+ns SRP pulses */
		| SRP_DATA | SRP_VBUS	/* accept both kinds of SRP pulse */
		;

	update_otg1(isp, isp1301_get_u8(isp, ISP1301_INTERRUPT_SOURCE));
	update_otg2(isp, isp1301_get_u8(isp, ISP1301_OTG_STATUS));

	check_state(isp, __func__);
	pr_debug("otg: %s, %s %06x\n",
			state_name(isp), __func__, OTG_CTRL_REG);

	OTG_IRQ_EN_REG = DRIVER_SWITCH | OPRT_CHG
			| B_SRP_TMROUT | B_HNP_FAIL
			| A_VBUS_ERR | A_SRP_DETECT | A_REQ_TMROUT;
	OTG_SYSCON_2_REG |= OTG_EN;

	return 0;
}
예제 #11
0
/*
	diagnostic code
*/
void peer_show()
{
	int i;
	__u16 * pp;
	__u8 * p8;
	char tbuf[64];
	ktime_t t;
	
	printf("Mode=%s,state=%s,flags=%08x,peermode=%s,%s.\n", ke_get_mode_name(kernelState), 
		state_name(get_state()), g_kernel.status.flags, ke_get_mode_name(peerState),
		ke_get_flag(FKERN_LED_SYNCHRONIZED)? "Synchronized":"Out of sync");
	pp=(__u16*)&g_kernel.status.prog_id;
	printf("  version : %04x-%04x-%04x-%04x\n", pp[0], pp[1], pp[2], pp[3]);
	pp=(__u16*)&g_kernel.peer_status.prog_id;
	printf("p-version : %04x-%04x-%04x-%04x\n", pp[0], pp[1], pp[2], pp[3]);
	p8=(__u8*)g_kernel.peer->localAddress;
	printf("Local addr: %02x-%02x-%02x-%02x-%02x-%02x\n",p8[0],p8[1],p8[2],p8[3],p8[4],p8[5]);
	p8=(__u8*)g_kernel.peer->peerAddress;
	printf("Peer addr : %02x-%02x-%02x-%02x-%02x-%02x\n",p8[0],p8[1],p8[2],p8[3],p8[4],p8[5]);
	t=ke_get_time();
	ke_time_to_string(t,tbuf,sizeof(tbuf));
	printf("Local time: %s\n",tbuf);
	ke_time_to_string(t+hspTimeOffset,tbuf,sizeof(tbuf));
	printf("Peer time : %s\n",tbuf);
	printf("Time Bias : %d milliseconds\n",hspTimeOffset/10/1000);
	printf("Counters  : ");
	for(i=0; i<sizeof peerCounters/sizeof peerCounters[0]; i++){
		printf("%d=%d,", i, peerCounters[i]);
	}
	printf("\n");
	ke_time_to_string(g_kernel.peer->lastMsgTime,tbuf,sizeof(tbuf));
	printf("Last msg from peer arrived at : %s\n",tbuf);
}
/*
This transitions the thread into a cooperative state where it's assumed to be suspended but can continue.

Native runtime code might want to put itself into a state where the thread is considered suspended but can keep running.
That state only works as long as the only managed state touched is blitable and was pinned before the transition.

It returns the action the caller must perform:

- Continue: Entered blocking state sucessfully;
- PollAndRetry: Async suspend raced and won, try to suspend and then retry;

*/
MonoDoBlockingResult
mono_threads_transition_do_blocking (MonoThreadInfo* info)
{
	int raw_state, cur_state, suspend_count;

retry_state_change:
	UNWRAP_THREAD_STATE (raw_state, cur_state, suspend_count, info);
	switch (cur_state) {

	case STATE_RUNNING: //transition to blocked
		g_assert (suspend_count == 0);
		if (InterlockedCompareExchange (&info->thread_state, build_thread_state (STATE_BLOCKING, suspend_count), raw_state) != raw_state)
			goto retry_state_change;
		trace_state_change ("DO_BLOCKING", info, raw_state, STATE_BLOCKING, 0);
		return DoBlockingContinue;

	case STATE_ASYNC_SUSPEND_REQUESTED:
		g_assert (suspend_count > 0);
		trace_state_change ("DO_BLOCKING", info, raw_state, cur_state, 0);
		return DoBlockingPollAndRetry;
/*
STATE_ASYNC_SUSPENDED
STATE_SELF_SUSPENDED: Code should not be running while suspended.
STATE_SELF_SUSPEND_REQUESTED: A blocking operation must not be done while trying to self suspend
STATE_BLOCKING:
STATE_BLOCKING_AND_SUSPENDED: Blocking is not nestabled
*/
	default:
		g_error ("Cannot transition thread %p from %s with DO_BLOCKING", info, state_name (cur_state));
	}
}
/*
This performs the last step of async suspend.

Returns TRUE if the caller should wait for resume.
*/
gboolean
mono_threads_transition_finish_async_suspend (MonoThreadInfo* info)
{
	int raw_state, cur_state, suspend_count;

retry_state_change:
	UNWRAP_THREAD_STATE (raw_state, cur_state, suspend_count, info);
	switch (cur_state) {

	case STATE_SELF_SUSPENDED: //async suspend raced with self suspend and lost
	case STATE_BLOCKING_AND_SUSPENDED: //async suspend raced with blocking and lost
		trace_state_change ("FINISH_ASYNC_SUSPEND", info, raw_state, cur_state, 0);
		return FALSE; //let self suspend wait

	case STATE_ASYNC_SUSPEND_REQUESTED:
		if (InterlockedCompareExchange (&info->thread_state, build_thread_state (STATE_ASYNC_SUSPENDED, suspend_count), raw_state) != raw_state)
			goto retry_state_change;
		trace_state_change ("FINISH_ASYNC_SUSPEND", info, raw_state, STATE_ASYNC_SUSPENDED, 0);
		return TRUE; //Async suspend worked, now wait for resume

/*
STATE_RUNNING: A thread cannot escape suspension once requested.
STATE_ASYNC_SUSPENDED: There can be only one suspend initiator at a given time, meaning this state should have been visible on the first stage of suspend.
STATE_SELF_SUSPEND_REQUESTED: When self suspend and async suspend happen together, they converge to async suspend so this state should not be visible.
STATE_BLOCKING: Async suspend only begins if a transition to async suspend requested happened. Blocking would have put us into blocking with positive suspend count if it raced with async finish.
*/
	default:
		g_error ("Cannot transition thread %p from %s with FINISH_ASYNC_SUSPEND", info, state_name (cur_state));
	}
}
/*
Check the current state of the thread and try to init a self suspend.
This must be called with self state saved.

Returns one of the following values:

- Resumed: Async resume happened and current thread should keep running
- Suspend: Caller should wait for a resume signal
- SelfSuspendNotifyAndWait: Notify the suspend initiator and wait for a resume signals
 suspend should start.

*/
MonoSelfSupendResult
mono_threads_transition_state_poll (MonoThreadInfo *info)
{
	int raw_state, cur_state, suspend_count;
	g_assert (info == mono_thread_info_current ());

retry_state_change:
	UNWRAP_THREAD_STATE (raw_state, cur_state, suspend_count, info);
	switch (cur_state) {
	case STATE_RUNNING:
		g_assert (suspend_count == 0);
		trace_state_change ("STATE_POLL", info, raw_state, cur_state, 0);
		return SelfSuspendResumed; //We're fine, don't suspend

	case STATE_ASYNC_SUSPEND_REQUESTED: //Async suspend requested, service it with a self suspend
	case STATE_SELF_SUSPEND_REQUESTED: //Start the self suspend process
		g_assert (suspend_count > 0);
		if (InterlockedCompareExchange (&info->thread_state, build_thread_state (STATE_SELF_SUSPENDED, suspend_count), raw_state) != raw_state)
			goto retry_state_change;
		trace_state_change ("STATE_POLL", info, raw_state, STATE_SELF_SUSPENDED, 0);
		if (cur_state == STATE_SELF_SUSPEND_REQUESTED)
			return SelfSuspendWait; //Caller should wait for resume
		else
			return SelfSuspendNotifyAndWait; //Caller should notify suspend initiator and wait for resume

/*
STATE_ASYNC_SUSPENDED: Code should not be running while suspended.
STATE_SELF_SUSPENDED: Code should not be running while suspended.
STATE_BLOCKING:
STATE_BLOCKING_AND_SUSPENDED: Pool is a local state transition. No VM activities are allowed while in blocking mode.
*/
	default:
		g_error ("Cannot transition thread %p from %s with STATE_POLL", info, state_name (cur_state));
	}
}
예제 #15
0
static void handle_session_event(WSPMachine *sm, WAPEvent *current_event, 
WSP_PDU *pdu) {
	debug("wap.wsp", 0, "WSP: machine %p, state %s, event %s",
		(void *) sm,
		state_name(sm->state), 
		wap_event_name(current_event->type));

	#define STATE_NAME(name)
	#define ROW(state_name, event, condition, action, next_state) \
		{ \
			struct event *e; \
			e = &current_event->u.event; \
			if (sm->state == state_name && \
			   current_event->type == event && \
			   (condition)) { \
				action \
				sm->state = next_state; \
				debug("wap.wsp", 0, "WSP %ld: New state %s", \
					sm->session_id, #next_state); \
				goto end; \
			} \
		}
	#include "wsp_server_session_states.def"
	
	cant_handle_event(sm, current_event);

end:
	wap_event_destroy(current_event);

	if (sm->state == NULL_SESSION)
		machine_destroy(sm);
}
예제 #16
0
파일: call.c 프로젝트: sealaunch/baresip
int call_debug(struct re_printf *pf, const struct call *call)
{
	int err;

	if (!call)
		return 0;

	err = re_hprintf(pf, "===== Call debug (%s) =====\n",
			 state_name(call->state));

	/* SIP Session debug */
	err |= re_hprintf(pf,
			  " local_uri: %s <%s>\n"
			  " peer_uri:  %s <%s>\n"
			  " af=%s\n",
			  call->local_name, call->local_uri,
			  call->peer_name, call->peer_uri,
			  net_af2name(call->af));
	err |= re_hprintf(pf, " direction: %s\n",
			  call->outgoing ? "Outgoing" : "Incoming");

	/* SDP debug */
	err |= sdp_session_debug(pf, call->sdp);

	return err;
}
/*
This is the transition that signals that a thread is no longer registered with the runtime.
Its main goal is to catch threads been witnessed after they detach.

This returns TRUE is the transition succeeded.
If it returns false it means that there's a pending suspend that should be acted upon.
*/
gboolean
mono_threads_transition_detach (MonoThreadInfo *info)
{
	int raw_state, cur_state, suspend_count;

retry_state_change:
	UNWRAP_THREAD_STATE (raw_state, cur_state, suspend_count, info);
	switch (cur_state) {
	case STATE_RUNNING:
		g_assert (suspend_count == 0);
		if (InterlockedCompareExchange (&info->thread_state, STATE_DETACHED, raw_state) != raw_state)
			goto retry_state_change;
		trace_state_change ("DETACH", info, raw_state, STATE_DETACHED, 0);
		return TRUE;
	case STATE_ASYNC_SUSPEND_REQUESTED: //Can't detach until whoever asked us to suspend to be happy with us
		return FALSE;
/*
STATE_ASYNC_SUSPENDED: Code should not be running while suspended.
STATE_SELF_SUSPENDED: Code should not be running while suspended.
STATE_SELF_SUSPEND_REQUESTED: This is a bug in the self suspend code that didn't execute the second part of it
STATE_BLOCKING: This is a bug in the coop code that forgot to do a finish blocking before exiting.
STATE_BLOCKING_AND_SUSPENDED: This is a bug in coop x suspend that resulted the thread in an undetachable state.
*/
	default:
		g_error ("Cannot transition current thread %p from %s with DETACH", info, state_name (cur_state));
	}
}
static int
isp1301_start_srp(struct otg_transceiver *dev)
{
	struct isp1301	*isp = container_of(dev, struct isp1301, otg);
	u32		otg_ctrl;

	if (!dev || isp != the_transceiver
			|| isp->otg.state != OTG_STATE_B_IDLE)
		return -ENODEV;

	otg_ctrl = omap_readl(OTG_CTRL);
	if (!(otg_ctrl & OTG_BSESSEND))
		return -EINVAL;

	otg_ctrl |= OTG_B_BUSREQ;
	otg_ctrl &= ~OTG_A_BUSREQ & OTG_CTRL_MASK;
	omap_writel(otg_ctrl, OTG_CTRL);
	isp->otg.state = OTG_STATE_B_SRP_INIT;

	pr_debug("otg: SRP, %s ... %06x\n", state_name(isp),
			omap_readl(OTG_CTRL));
#ifdef	CONFIG_USB_OTG
	check_state(isp, __func__);
#endif
	return 0;
}
예제 #19
0
파일: call.c 프로젝트: aKlausKranz/baresip
int call_info(struct re_printf *pf, const struct call *call)
{
	if (!call)
		return 0;

	return re_hprintf(pf, "%H  %8s  %s", print_duration, call,
			  state_name(call->state), call->peer_uri);
}
예제 #20
0
DSME_HANDLER(DSM_MSGTYPE_STATE_CHANGE_IND, conn, msg)
{
    write_log("Received: dsme internal state", state_name(msg->state));
    if (saved_shutdown_reason == SD_REASON_UNKNOWN) {
        if (msg->state == DSME_STATE_SHUTDOWN)
            saved_shutdown_reason = SD_SW_SHUTDOWN;
        else if (msg->state == DSME_STATE_REBOOT)
            saved_shutdown_reason = SD_SW_REBOOT;
    }
}
예제 #21
0
DSME_HANDLER(DSM_MSGTYPE_STATE_QUERY, client, msg)
{
  DSM_MSGTYPE_STATE_CHANGE_IND ind_msg =
    DSME_MSG_INIT(DSM_MSGTYPE_STATE_CHANGE_IND);

  dsme_log(LOG_DEBUG, PFIX"state_query, state: %s", state_name(current_state));

  ind_msg.state = current_state;
  endpoint_send(client, &ind_msg);
}
예제 #22
0
    HPX_EXPORT std::exception_ptr
    get_exception(Exception const& e, std::string const& func,
        std::string const& file, long line, std::string const& auxinfo)
    {
        if (is_of_lightweight_hpx_category(e))
            return construct_lightweight_exception(e, func, file, line);

        std::int64_t pid = ::getpid();
        std::string back_trace(backtrace());

        std::string state_name("not running");
        std::string hostname;
        hpx::runtime* rt = get_runtime_ptr();
        if (rt)
        {
            state rts_state = rt->get_state();
            state_name = get_runtime_state_name(rts_state);

            if (rts_state >= state_initialized &&
                rts_state < state_stopped)
            {
                std::ostringstream strm;
                strm << get_runtime().here();
                hostname = strm.str();
            }
        }

        // if this is not a HPX thread we do not need to query neither for
        // the shepherd thread nor for the thread id
        error_code ec(lightweight);
        std::uint32_t node = get_locality_id(ec);

        std::size_t shepherd = std::size_t(-1);
        threads::thread_id_type thread_id;
        util::thread_description thread_name;

        threads::thread_self* self = threads::get_self_ptr();
        if (nullptr != self)
        {
            if (threads::threadmanager_is(state_running))
                shepherd = hpx::get_worker_thread_num();

            thread_id = threads::get_self_id();
            thread_name = threads::get_thread_description(thread_id);
        }

        std::string env(get_execution_environment());
        std::string config(configuration_string());

        return construct_exception(e, func, file, line, back_trace, node,
            hostname, pid, shepherd,
            reinterpret_cast<std::size_t>(thread_id.get()),
            util::as_string(thread_name), env, config,
            state_name, auxinfo);
    }
예제 #23
0
static void state_machine(MSBitrateController *obj){
	MSRateControlAction action = {0};
	switch(obj->state){
		case Stable:
			obj->stable_count++;
		case Init:
			ms_qos_analyzer_suggest_action(obj->analyzer,&action);
			if (action.type!=MSRateControlActionDoNothing){
				execute_action(obj,&action);
				obj->state=Probing;
			}else if (obj->stable_count>=probing_up_interval){
				action.type=MSRateControlActionIncreaseQuality;
				action.value=10;
				execute_action(obj,&action);
				obj->state=ProbingUp;
				obj->probing_up_count=0;
			}
		break;
		case Probing:
			obj->stable_count=0;
			if (ms_qos_analyzer_has_improved(obj->analyzer)){
				obj->state=Stable;
			}else{
				ms_qos_analyzer_suggest_action(obj->analyzer,&action);
				if (action.type!=MSRateControlActionDoNothing){
					execute_action(obj,&action);
				}
			}
		break;
		case ProbingUp:
			obj->stable_count=0;
			obj->probing_up_count++;
			ms_qos_analyzer_suggest_action(obj->analyzer,&action);
			if (action.type!=MSRateControlActionDoNothing){
				execute_action(obj,&action);
				obj->state=Probing;
			}else{
				/*continue with slow ramp up*/
				if (obj->probing_up_count==2){
					action.type=MSRateControlActionIncreaseQuality;
					action.value=10;
					if (execute_action(obj,&action)==-1){
						/* we reached the maximum*/
						obj->state=Init;
					}
					obj->probing_up_count=0;
				}
			}
		break;
		default:
		break;
	}
	ms_message("MSBitrateController: current state is %s",state_name(obj->state));
}
예제 #24
0
static void
dump_regs(struct isp1301 *isp, const char *label)
{
	u8	ctrl = isp1301_get_u8(isp, ISP1301_OTG_CONTROL_1);
	u8	status = isp1301_get_u8(isp, ISP1301_OTG_STATUS);
	u8	src = isp1301_get_u8(isp, ISP1301_INTERRUPT_SOURCE);

	pr_debug("otg: %06x, %s %s, otg/%02x stat/%02x.%02x\n",
		omap_readl(OTG_CTRL), label, state_name(isp),
		ctrl, status, src);
	/* mode control and irq enables don't change much */
}
static int
isp1301_start_hnp(struct otg_transceiver *dev)
{
#ifdef	CONFIG_USB_OTG
	struct isp1301	*isp = container_of(dev, struct isp1301, otg);
	u32 l;

	if (!dev || isp != the_transceiver)
		return -ENODEV;
	if (isp->otg.default_a && (isp->otg.host == NULL
			|| !isp->otg.host->b_hnp_enable))
		return -ENOTCONN;
	if (!isp->otg.default_a && (isp->otg.gadget == NULL
			|| !isp->otg.gadget->b_hnp_enable))
		return -ENOTCONN;

	/* We want hardware to manage most HNP protocol timings.
	 * So do this part as early as possible...
	 */
	switch (isp->otg.state) {
	case OTG_STATE_B_HOST:
		isp->otg.state = OTG_STATE_B_PERIPHERAL;
		/* caller will suspend next */
		break;
	case OTG_STATE_A_HOST:
#if 0
		/* autoconnect mode avoids irq latency bugs */
		isp1301_set_bits(isp, ISP1301_MODE_CONTROL_1,
				MC1_BDIS_ACON_EN);
#endif
		/* caller must suspend then clear A_BUSREQ */
		usb_gadget_vbus_connect(isp->otg.gadget);
		l = omap_readl(OTG_CTRL);
		l |= OTG_A_SETB_HNPEN;
		omap_writel(l, OTG_CTRL);

		break;
	case OTG_STATE_A_PERIPHERAL:
		/* initiated by B-Host suspend */
		break;
	default:
		return -EILSEQ;
	}
	pr_debug("otg: HNP %s, %06x ...\n",
		state_name(isp), omap_readl(OTG_CTRL));
	check_state(isp, __func__);
	return 0;
#else
	/* srp-only */
	return -EINVAL;
#endif
}
/*
This transition initiates the suspension of another thread.

Returns one of the following values:

- AsyncSuspendInitSuspend: Thread suspend requested, async suspend needs to be done.
- AsyncSuspendAlreadySuspended: Thread already suspended, nothing to do.
- AsyncSuspendWait: Self suspend in progress, asked it to notify us. Caller must add target to the notification set.
*/
MonoRequestAsyncSuspendResult
mono_threads_transition_request_async_suspension (MonoThreadInfo *info)
{
	int raw_state, cur_state, suspend_count;
	g_assert (info != mono_thread_info_current ());

retry_state_change:
	UNWRAP_THREAD_STATE (raw_state, cur_state, suspend_count, info);

	switch (cur_state) {
	case STATE_RUNNING: //Post an async suspend request
		g_assert (suspend_count == 0);
		if (InterlockedCompareExchange (&info->thread_state, build_thread_state (STATE_ASYNC_SUSPEND_REQUESTED, 1), raw_state) != raw_state)
			goto retry_state_change;
		trace_state_change ("ASYNC_SUSPEND_REQUESTED", info, raw_state, STATE_ASYNC_SUSPEND_REQUESTED, 1);
		return AsyncSuspendInitSuspend; //This is the first async suspend request against the target

	case STATE_ASYNC_SUSPENDED:
	case STATE_SELF_SUSPENDED: //Async suspend can suspend the same thread multiple times as it starts from the outside
	case STATE_BLOCKING_AND_SUSPENDED:
		g_assert (suspend_count > 0 && suspend_count < THREAD_SUSPEND_COUNT_MAX);
		if (InterlockedCompareExchange (&info->thread_state, build_thread_state (cur_state, suspend_count + 1), raw_state) != raw_state)
			goto retry_state_change;
		trace_state_change ("ASYNC_SUSPEND_REQUESTED", info, raw_state, cur_state, 1);
		return AsyncSuspendAlreadySuspended; //Thread is already suspended so we don't need to wait it to suspend

	case STATE_SELF_SUSPEND_REQUESTED: //This suspend needs to notify the initiator, so we need to promote the suspend to async
		g_assert (suspend_count > 0 && suspend_count < THREAD_SUSPEND_COUNT_MAX);
		if (InterlockedCompareExchange (&info->thread_state, build_thread_state (STATE_ASYNC_SUSPEND_REQUESTED, suspend_count + 1), raw_state) != raw_state)
			goto retry_state_change;
		trace_state_change ("ASYNC_SUSPEND_REQUESTED", info, raw_state, STATE_ASYNC_SUSPEND_REQUESTED, 1);
		return AsyncSuspendWait; //This is the first async suspend request, change the thread and let it notify us [1]

	case STATE_BLOCKING:
		g_assert (suspend_count < THREAD_SUSPEND_COUNT_MAX);
		if (InterlockedCompareExchange (&info->thread_state, build_thread_state (cur_state, suspend_count + 1), raw_state) != raw_state)
			goto retry_state_change;
		trace_state_change ("ASYNC_SUSPEND_REQUESTED", info, raw_state, cur_state, 1);
		return AsyncSuspendAlreadySuspended; //A thread in the blocking state has its state saved so we can treat it as suspended.

/*

[1] It's questionable on what to do if we hit the beginning of a self suspend.
The expected behavior is that the target should poll its state very soon so the the suspend latency should be minimal.

STATE_ASYNC_SUSPEND_REQUESTED: Since there can only be one async suspend in progress and it must finish, it should not be possible to witness this.
*/
	default:
		g_error ("Cannot transition thread %p from %s with ASYNC_SUSPEND_REQUESTED", info, state_name (cur_state));
	}
	return FALSE;
}
예제 #27
0
void Player::StateApply(const char* name_, int turn_)
{
	for(list<state_name>::iterator it=state_list.begin();it!=state_list.end();it++)
	{
		if(!it->name.compare(name_))
		{
			if(it->turn < turn_)
				it->turn  = turn_;
			return;
		}
	}
	state_list.push_back(state_name(name_,turn_));
}
예제 #28
0
static void
write_all_states(unsigned int states)
{
	unsigned int lowbit;

	/* A trick for computing the lowest set bit. */
	while ((lowbit = states & (-states)) != 0) {
		states &= ~lowbit;		/* Clear the low bit. */
		errmsg(state_name(lowbit));
		if (states != 0)
			errmsg("/");
	}
}
예제 #29
0
void _set_state(enum hsp_state_t s,const char * fnc, int line)
{
	if(s == _state){
		return;
	}
#if defined(HSP_DEBUG)
	{
		ktime_t t;
		t = ke_get_time() - tBase;
		hsp_log(("%d, state change %s->%s, file %s,line %d\n", (int)(t/10000),state_name(_state),state_name(s),fnc,line));
	}
#endif
	_state = s;
}
예제 #30
0
/**
 * This function sends a message to clients to notify about state change.
 * SAVE_DATA message is also sent when going down.
 * @param state State that is being activated
 */
static void change_state(dsme_state_t new_state)
{
  if (new_state == DSME_STATE_SHUTDOWN ||
      new_state == DSME_STATE_ACTDEAD  || 
      new_state == DSME_STATE_REBOOT)
  {
      DSM_MSGTYPE_SAVE_DATA_IND save_msg =
        DSME_MSG_INIT(DSM_MSGTYPE_SAVE_DATA_IND);

      dsme_log(LOG_DEBUG, PFIX"sending SAVE_DATA");
      broadcast(&save_msg);
  }

  DSM_MSGTYPE_STATE_CHANGE_IND ind_msg =
    DSME_MSG_INIT(DSM_MSGTYPE_STATE_CHANGE_IND);

  ind_msg.state = new_state;
  dsme_log(LOG_DEBUG, PFIX"STATE_CHANGE_IND sent (%s)", state_name(new_state));
  broadcast(&ind_msg);

  dsme_log(LOG_NOTICE, PFIX"new state: %s", state_name(new_state));
  current_state = new_state;
}