add: dprintf("resched(): suspending thread 0x%lx\n", old_thread->id);
context: resched(void){#ifndef NEW_SCHEDULER	struct thread *next_thread = NULL;	int last_thread_pri = -1;#else /* NEW_SCHEDULER */	struct thread *next_thread, *prev_thread = NULL;#endif /* NEW_SCHEDULER */	struct thread *old_thread = thread_get_current_thread();#ifndef NEW_SCHEDULER	int i;#endif /* not NEW_SCHEDULER */	bigtime_t quantum;	timer *quantum_timer;#ifndef NEW_SCHEDULER//	dprintf("top of thread_resched: cpu %d, cur_thread = 0x%x\n", smp_get_current_cpu(), thread_get_current_thread());#else /* NEW_SCHEDULER *///	dprintf("resched(): cpu %d, cur_thread = 0x%x\n", smp_get_current_cpu(), thread_get_current_thread());#endif /* NEW_SCHEDULER */	switch(old_thread->next_state) {		case B_THREAD_RUNNING:		case B_THREAD_READY://			dprintf("enqueueing thread 0x%x into run q. pri = %d\n", old_thread, old_thread->priority);			thread_enqueue_run_q(old_thread);			break;		case B_THREAD_SUSPENDED:#ifndef NEW_SCHEDULER			dprintf("suspending thread 0x%lx\n", old_thread->id);#else /* NEW_SCHEDULER */			dprintf("resched(): suspending thread 0x%x\n", old_thread->id);#endif /* NEW_SCHEDULER */			break;		case THREAD_STATE_FREE_ON_RESCHED:			// This will hopefully be eliminated once the slab			// allocator is done			thread_enqueue(old_thread, &dead_q);			break;		default://			dprintf("not enqueueing thread 0x%x into run q. next_state = %d\n", old_thread, old_thread->next_state);			;	}	old_thread->state = old_thread->next_state;#ifndef NEW_SCHEDULER	// search the real-time queue	for(i = B_MAX_PRIORITY; i >= B_FIRST_REAL_TIME_PRIORITY; i-=2) {		next_thread = thread_dequeue_run_q(i);		if(next_thread)			goto found_thread;	}	// search the regular queue	for(i = B_FIRST_REAL_TIME_PRIORITY - 1; i >= B_LOWEST_ACTIVE_PRIORITY; i-=2) {		next_thread = thread_lookat_run_q(i);		if(next_thread != NULL) {			// skip it sometimes			if(_rand() > 0x3000) {				next_thread = thread_dequeue_run_q(i);				goto found_thread;			}			last_thread_pri = i;			next_thread = NULL;		}	}	if(next_thread == NULL) {		if(last_thread_pri != -1) {			next_thread = thread_dequeue_run_q(last_thread_pri);			if(next_thread == NULL)				panic("next_thread == NULL! last_thread_pri = %d\n", last_thread_pri);		} else {			next_thread = thread_dequeue_run_q(B_IDLE_PRIORITY);			if(next_thread == NULL)				panic("next_thread == NULL! no idle priorities!\n");		}#else /* NEW_SCHEDULER */	// select next thread from the run queue	next_thread = run_q.head;	while ((next_thread) && (next_thread->priority > B_IDLE_PRIORITY)) {		// always extract real time threads		if (next_thread->priority >= B_FIRST_REAL_TIME_PRIORITY)			break;		// never skip last non-idle normal thread		if (next_thread->q_next && (next_thread->q_next->priority == B_IDLE_PRIORITY))			break;		// skip normal threads sometimes		if (_rand() > 0x3000)			break;		prev_thread = next_thread;		next_thread = next_thread->q_next;#endif /* NEW_SCHEDULER */	}#ifndef NEW_SCHEDULERfound_thread:#else /* NEW_SCHEDULER */	if (!next_thread)		panic("resched(): run queue is empty!\n");			// extract selected thread from the run queue	if (prev_thread)		prev_thread->q_next = next_thread->q_next;	else		run_q.head = next_thread->q_next;	#endif /* NEW_SCHEDULER */	next_thread->state = B_THREAD_RUNNING;	next_thread->next_state = B_THREAD_READY;		if ((next_thread != old_thread) || (old_thread->cpu->info.preempted)) {		// XXX calculate quantum		quantum = 3000;		quantum_timer = &old_thread->cpu->info.quantum_timer;		if (!old_thread->cpu->info.preempted)			_local_timer_cancel_event(old_thread->cpu->info.cpu_num, quantum_timer);		old_thread->cpu->info.preempted = 0;		add_timer(quantum_timer, &reschedule_event, quantum, B_ONE_SHOT_RELATIVE_TIMER);		if (next_thread != old_thread)			context_switch(old_thread, next_thread);	}#ifndef NEW_SCHEDULER#if 0	// XXX should only reset the quantum timer if we are switching to a new thread,	// or we got here as a result of a quantum expire.	// XXX calculate quantum	quantum = 10000;	// get the quantum timer for this cpu	quantum_timer = &old_thread->cpu->info.quantum_timer;	if(!old_thread->cpu->info.preempted) {		_local_timer_cancel_event(old_thread->cpu->info.cpu_num, quantum_timer);	}	old_thread->cpu->info.preempted = 0;	add_timer(quantum_timer, &reschedule_event, quantum, B_ONE_SHOT_RELATIVE_TIMER);	if(next_thread != old_thread) {//		dprintf("thread_resched: cpu %d switching from thread %d to %d\n",//			smp_get_current_cpu(), old_thread->id, next_thread->id);		context_switch(old_thread, next_thread);	}#endif#endif /* not NEW_SCHEDULER */}