commit 8e791c295ff1004c6ddd6f0535418fe0f8363199
parent 44c6403f317da166dfc0621e7e6a42bb16a2178d
Author: oblique <psyberbits@gmail.com>
Date: Tue, 13 Nov 2012 07:08:41 +0200
fix a race-condition in semaphore_wait()
Diffstat:
1 file changed, 3 insertions(+), 0 deletions(-)
diff --git a/include/semaphore.h b/include/semaphore.h
@@ -1,6 +1,7 @@
#ifndef __SEMAPHORE_H
#define __SEMAPHORE_H
+#include <irq.h>
#include <io.h>
#include <spinlock.h>
#include <sched.h>
@@ -45,8 +46,10 @@ semaphore_wait(semaphore_t *sem)
while (1) {
spinlock_lock(&sem->lock);
if (sem->counter == 0) {
+ sched_disable();
suspend_task_no_schedule((u32)sem);
spinlock_unlock(&sem->lock);
+ sched_enable();
schedule();
continue;
}