Exemplo n.º 1
0
/*
 * Locks the runqueue itself.
 *
 * Thread must be locked.
 */
static boolean_t
sched_traditional_processor_queue_remove(processor_t processor,
                                         thread_t thread)
{
	processor_set_t pset;
	run_queue_t     rq;

	pset = processor->processor_set;
	pset_lock(pset);

	rq = runq_for_processor(processor);

	if (processor == thread->runq) {
		/*
		 * Thread is on a run queue and we have a lock on
		 * that run queue.
		 */
		runq_consider_decr_bound_count(processor, thread);
		run_queue_remove(rq, thread);
	}
	else {
		/*
		 * The thread left the run queue before we could
		 * lock the run queue.
		 */
		assert(thread->runq == PROCESSOR_NULL);
		processor = PROCESSOR_NULL;
	}

	pset_unlock(pset);

	return (processor != PROCESSOR_NULL);
}
Exemplo n.º 2
0
static void _exited_kthread() {

  spinlock_lock(&run_queue->spinlock);

  _BUG_ON(run_queue->running==0); // CANT QUIT IDLE TASK!
  
  struct kthread * c = run_queue_current();

  if(c) {
    run_queue_remove(c);
    c->flags |= KTHREAD_JOINABLE; 
  }

  spinlock_unlock(&run_queue->spinlock);
  
  kthread_yield();

  _BUG();
  
  _asm_idle_task(NULL);
}