void __ssx_thread_unmap(SsxThread* thread) { SsxThreadPriority priority; priority = thread->priority; __ssx_priority_map[priority] = 0; if (__ssx_thread_is_runnable(thread)) { thread->state = SSX_THREAD_STATE_SUSPENDED_RUNNABLE; __ssx_thread_queue_delete(&__ssx_run_queue, priority); } else { thread->state = SSX_THREAD_STATE_SUSPENDED_BLOCKED; if (thread->flags & SSX_THREAD_FLAG_SEMAPHORE_PEND) { __ssx_thread_queue_delete(&(thread->semaphore->pending_threads), priority); } } }
int ssx_sleep_absolute(SsxTimebase time) { SsxMachineContext ctx; SsxThread *current; if (SSX_ERROR_CHECK_API) { SSX_ERROR_UNLESS_THREAD_CONTEXT(); } ssx_critical_section_enter(SSX_NONCRITICAL, &ctx); current = (SsxThread *)__ssx_current_thread; current->timer.timeout = time; __ssx_timer_schedule(&(current->timer)); current->flags |= SSX_THREAD_FLAG_TIMER_PEND; SSX_TRACE_THREAD_SLEEP(current->priority); __ssx_thread_queue_delete(&__ssx_run_queue, current->priority); __ssx_schedule(); current->flags &= ~(SSX_THREAD_FLAG_TIMER_PEND | SSX_THREAD_FLAG_TIMED_OUT); ssx_critical_section_exit(&ctx); return SSX_OK; }