bug in ticket lock! => switch (temporary) to a "normal" spinlock

This commit is contained in:
Stefan Lankes 2011-08-26 03:11:58 -07:00
parent 297421e29d
commit 5e047d6b96

View file

@ -92,12 +92,16 @@ inline static int spinlock_lock(spinlock_t* s) {
return 0;
}
#if 0
ticket = atomic_int32_inc(&s->queue);
while(atomic_int32_read(&s->dequeue) != ticket) {
NOP1;
}
s->owner = curr_task->id;
s->counter = 1;
#else
while( atomic_int32_test_and_set(&s->dequeue,0) );
#endif
return 0;
}
@ -114,7 +118,11 @@ inline static int spinlock_unlock(spinlock_t* s) {
s->counter--;
if (!s->counter) {
s->owner = MAX_TASKS;
#if 0
atomic_int32_inc(&s->dequeue);
#else
atomic_int32_set(&s->dequeue,1);
#endif
}
return 0;