Subversion Repositories HelenOS-historic

Compare Revisions

Ignore whitespace Rev 778 → Rev 779

/kernel/trunk/generic/include/cpu.h
57,11 → 57,6
SPINLOCK_DECLARE(timeoutlock);
link_t timeout_active_head;
 
#ifdef CONFIG_SMP
atomic_t kcpulbstarted;
waitq_t kcpulb_wq;
#endif /* CONFIG_SMP */
 
/**
* Processor ID assigned by kernel.
*/
/kernel/trunk/generic/src/proc/scheduler.c
133,22 → 133,10
interrupts_enable();
if (n == 0) {
#ifdef CONFIG_SMP
/*
* If the load balancing thread is not running, wake it up and
* set CPU-private flag that the kcpulb has been started.
*/
if (test_and_set(&CPU->kcpulbstarted) == 0) {
waitq_wakeup(&CPU->kcpulb_wq, 0);
goto loop;
}
#endif /* CONFIG_SMP */
/*
* For there was nothing to run, the CPU goes to sleep
* until a hardware interrupt or an IPI comes.
* This improves energy saving and hyperthreading.
* On the other hand, several hardware interrupts can be ignored.
*/
cpu_sleep();
goto loop;
481,9 → 469,9
 
loop:
/*
* Sleep until there's some work to do.
* Work in 1s intervals.
*/
waitq_sleep(&CPU->kcpulb_wq);
thread_sleep(1);
 
not_satisfied:
/*
578,7 → 566,7
*/
spinlock_lock(&t->lock);
#ifdef KCPULB_VERBOSE
printf("kcpulb%d: TID %d -> cpu%d, nrdy=%d, avg=%d\n", CPU->id, t->tid, CPU->id, CPU->nrdy, nrdy / config.cpu_active);
printf("kcpulb%d: TID %d -> cpu%d, nrdy=%d, avg=%d\n", CPU->id, t->tid, CPU->id, CPU->nrdy, atomic_get(&nrdy) / config.cpu_active);
#endif
t->flags |= X_STOLEN;
spinlock_unlock(&t->lock);
606,22 → 594,17
* Be a little bit light-weight and let migrated threads run.
*/
scheduler();
}
else {
} else {
/*
* We failed to migrate a single thread.
* Something more sophisticated should be done.
* Give up this turn.
*/
scheduler();
goto loop;
}
goto not_satisfied;
 
satisfied:
/*
* Tell find_best_thread() to wake us up later again.
*/
atomic_set(&CPU->kcpulbstarted,0);
goto loop;
}
 
655,7 → 638,7
spinlock_unlock(&r->lock);
continue;
}
printf("Rq %d: ", i);
printf("\tRq %d: ", i);
for (cur=r->rq_head.next; cur!=&r->rq_head; cur=cur->next) {
t = list_get_instance(cur, thread_t, rq_link);
printf("%d(%s) ", t->tid,
/kernel/trunk/generic/src/cpu/cpu.c
67,10 → 67,6
spinlock_initialize(&cpus[i].lock, "cpu_t.lock");
 
#ifdef CONFIG_SMP
waitq_initialize(&cpus[i].kcpulb_wq);
#endif /* __SMP */
for (j = 0; j < RQ_COUNT; j++) {
spinlock_initialize(&cpus[i].rq[j].lock, "rq_t.lock");
list_initialize(&cpus[i].rq[j].rq_head);