/*! * Put given thread or active thread (when kthread == NULL) into queue 'q_id' * - if kthread != NULL, thread must not be in any list and 'kthreads_schedule' * should follow this call before exiting from kernel! */ void kthread_enqueue ( kthread_t *kthread, kthread_q *q ) { ASSERT ( ( kthread || active_thread ) && q ); if ( !kthread ) kthread = active_thread; kthread->state.state = THR_STATE_WAIT; kthread->queue = q; kthreadq_append ( kthread->queue, kthread ); }
/*! * Put given thread or active thread (when kthread == NULL) into queue 'q_id' * - if kthread != NULL, thread must not be in any list and * 'kthreads_schedule' should follow this call before exiting from kernel! * \param kthread thread descriptor * \param q queue where to put thread * \param sig_int is thread interruptable while in queue? * \param wakeup_action if thread is interruptable on interrupt call this * \param param param for "wakeup_action" */ void kthread_enqueue ( kthread_t *kthread, kthread_q *q, int sig_int, void *wakeup_action, void *param ) { ASSERT ( ( kthread || active_thread ) && q ); if ( !kthread ) kthread = active_thread; kthread->state.state = THR_STATE_WAIT; kthread->queue = q; kthread->state.sig_int = sig_int; if ( sig_int && wakeup_action == NULL ) wakeup_action = kthread_release_prematurely; kthread_set_signal_interrupt_handler ( kthread, wakeup_action, param ); kthreadq_append ( kthread->queue, kthread ); }
/*! * Move given thread (its descriptor) to ready threads * (as last or first in its priority queue) */ void kthread_move_to_ready ( kthread_t *kthread, int where ) { int i, j, prio; ASSERT ( kthread ); prio = kthread_get_prio ( kthread ); kthread_mark_ready ( kthread ); kthread_set_queue ( kthread, &ready.rq[prio] ); if ( where == LAST ) kthreadq_append ( &ready.rq[prio], kthread ); else kthreadq_prepend ( &ready.rq[prio], kthread ); /* mark that list as not empty */ i = prio / UINT_SIZE; j = prio % UINT_SIZE; ready.mask[i] |= (uint) ( 1 << j ); }