rem: TRACE(("enqueueing thread 0x%x into run q. pri = %d\n", oldThread, oldThread->priority));
add: TRACE(("enqueueing thread 0x%lx into run q. pri = %d\n", oldThread->id, oldThread->priority));
context: scheduler_reschedule(void){	struct thread *oldThread = thread_get_current_thread();	struct thread *nextThread, *prevThread;	TRACE(("reschedule(): cpu %d, cur_thread = 0x%x\n", smp_get_current_cpu(), thread_get_current_thread()));	switch (oldThread->next_state) {		case B_THREAD_RUNNING:		case B_THREAD_READY:			TRACE(("enqueueing thread 0x%x into run q. pri = %d\n", oldThread, oldThread->priority));			scheduler_enqueue_in_run_queue(oldThread);			break;		case B_THREAD_SUSPENDED:			TRACE(("reschedule(): suspending thread 0x%lx\n", oldThread->id));			break;		case THREAD_STATE_FREE_ON_RESCHED:			// This will hopefully be eliminated once the slab			// allocator is done			thread_enqueue(oldThread, &dead_q);			break;		default:			TRACE(("not enqueueing thread 0x%x into run q. next_state = %d\n", old_thread, old_thread->next_state));			break;	}	oldThread->state = oldThread->next_state;	// select next thread from the run queue	nextThread = sRunQueue.head;	prevThread = NULL;	while (nextThread && (nextThread->priority > B_IDLE_PRIORITY)) {		// always extract real time threads		if (nextThread->priority >= B_FIRST_REAL_TIME_PRIORITY)			break;		// never skip last non-idle normal thread		if (nextThread->queue_next && (nextThread->queue_next->priority == B_IDLE_PRIORITY))			break;		// skip normal threads sometimes		if (_rand() > 0x3000)			break;		prevThread = nextThread;		nextThread = nextThread->queue_next;	}	if (!nextThread)		panic("reschedule(): run queue is empty!\n");	// extract selected thread from the run queue	if (prevThread)		prevThread->queue_next = nextThread->queue_next;	else		sRunQueue.head = nextThread->queue_next;	nextThread->state = B_THREAD_RUNNING;	nextThread->next_state = B_THREAD_READY;	if (nextThread != oldThread || oldThread->cpu->info.preempted) {		bigtime_t quantum = 3000;	// ToDo: calculate quantum!		timer *quantum_timer= &oldThread->cpu->info.quantum_timer;		if (!oldThread->cpu->info.preempted)			_local_timer_cancel_event(oldThread->cpu->info.cpu_num, quantum_timer);		oldThread->cpu->info.preempted = 0;		add_timer(quantum_timer, &reschedule_event, quantum, B_ONE_SHOT_RELATIVE_TIMER);		if (nextThread != oldThread)			context_switch(oldThread, nextThread);	}}