regression: elf loading
[lunaix-os.git] / lunaix-os / kernel / ds / waitq.c
index 4b5abfd89055024a75bd4f220c808ef9c0b14e33..7045e36731cfc3db8adf5f68d6f099fa2ef244b8 100644 (file)
@@ -5,6 +5,9 @@
 void
 pwait(waitq_t* queue)
 {
+    // prevent race condition.
+    cpu_disable_interrupt();
+
     waitq_t* current_wq = &__current->waitqueue;
     assert(llist_empty(&current_wq->waiters));
 
@@ -12,6 +15,8 @@ pwait(waitq_t* queue)
 
     block_current();
     sched_yieldk();
+
+    cpu_enable_interrupt();
 }
 
 void
@@ -42,6 +47,7 @@ pwake_all(waitq_t* queue)
     {
         proc = container_of(pos, struct proc_info, waitqueue);
 
+        assert(proc->state == PS_BLOCKED);
         proc->state = PS_READY;
         llist_delete(&pos->waiters);
     }