Subversion Repositories HelenOS-historic

Compare Revisions

Ignore whitespace Rev 11 → Rev 15

/SPARTAN/trunk/src/time/delay.c
41,6 → 41,6
pri_t pri;
 
pri = cpu_priority_high();
asm_delay_loop(microseconds * the->cpu->delay_loop_const);
asm_delay_loop(microseconds * CPU->delay_loop_const);
cpu_priority_restore(pri);
}
/SPARTAN/trunk/src/time/timeout.c
39,8 → 39,8
 
void timeout_init(void)
{
spinlock_initialize(&the->cpu->timeoutlock);
list_initialize(&the->cpu->timeout_active_head);
spinlock_initialize(&CPU->timeoutlock);
list_initialize(&CPU->timeout_active_head);
}
 
 
70,13 → 70,13
__u64 sum;
 
pri = cpu_priority_high();
spinlock_lock(&the->cpu->timeoutlock);
spinlock_lock(&CPU->timeoutlock);
spinlock_lock(&t->lock);
if (t->cpu)
panic("timeout_register: t->cpu != 0");
 
t->cpu = the->cpu;
t->cpu = CPU;
t->ticks = us2ticks(time);
t->handler = f;
86,8 → 86,8
* Insert t into the active timeouts list according to t->ticks.
*/
sum = 0;
l = the->cpu->timeout_active_head.next;
while (l != &the->cpu->timeout_active_head) {
l = CPU->timeout_active_head.next;
while (l != &CPU->timeout_active_head) {
hlp = list_get_instance(l, timeout_t, link);
spinlock_lock(&hlp->lock);
if (t->ticks < sum + hlp->ticks) {
109,7 → 109,7
/*
* Decrease ticks of t's immediate succesor by t->ticks.
*/
if (l != &the->cpu->timeout_active_head) {
if (l != &CPU->timeout_active_head) {
spinlock_lock(&hlp->lock);
hlp->ticks -= t->ticks;
spinlock_unlock(&hlp->lock);
116,7 → 116,7
}
 
spinlock_unlock(&t->lock);
spinlock_unlock(&the->cpu->timeoutlock);
spinlock_unlock(&CPU->timeoutlock);
cpu_priority_restore(pri);
}
 
/SPARTAN/trunk/src/time/clock.c
57,8 → 57,8
* To avoid lock ordering problems,
* run all expired timeouts as you visit them.
*/
spinlock_lock(&the->cpu->timeoutlock);
while ((l = the->cpu->timeout_active_head.next) != &the->cpu->timeout_active_head) {
spinlock_lock(&CPU->timeoutlock);
while ((l = CPU->timeout_active_head.next) != &CPU->timeout_active_head) {
h = list_get_instance(l, timeout_t, link);
spinlock_lock(&h->lock);
if (h->ticks-- != 0) {
70,30 → 70,30
arg = h->arg;
timeout_reinitialize(h);
spinlock_unlock(&h->lock);
spinlock_unlock(&the->cpu->timeoutlock);
spinlock_unlock(&CPU->timeoutlock);
 
f(arg);
 
spinlock_lock(&the->cpu->timeoutlock);
spinlock_lock(&CPU->timeoutlock);
}
spinlock_unlock(&the->cpu->timeoutlock);
spinlock_unlock(&CPU->timeoutlock);
 
/*
* Do CPU usage accounting and find out whether to preempt the->thread.
* Do CPU usage accounting and find out whether to preempt THREAD.
*/
 
if (the->thread) {
spinlock_lock(&the->cpu->lock);
the->cpu->needs_relink++;
spinlock_unlock(&the->cpu->lock);
if (THREAD) {
spinlock_lock(&CPU->lock);
CPU->needs_relink++;
spinlock_unlock(&CPU->lock);
spinlock_lock(&the->thread->lock);
if (!the->thread->ticks--) {
spinlock_unlock(&the->thread->lock);
spinlock_lock(&THREAD->lock);
if (!THREAD->ticks--) {
spinlock_unlock(&THREAD->lock);
scheduler();
}
else {
spinlock_unlock(&the->thread->lock);
spinlock_unlock(&THREAD->lock);
}
}