X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/e6416905c4afb34e61276cdc07c44813a3ebc5e7..43c43c058ededea929645fef68d15820eed1f5e9:/lunaix-os/kernel/ds/waitq.c diff --git a/lunaix-os/kernel/ds/waitq.c b/lunaix-os/kernel/ds/waitq.c index 4b5abfd..7045e36 100644 --- a/lunaix-os/kernel/ds/waitq.c +++ b/lunaix-os/kernel/ds/waitq.c @@ -5,6 +5,9 @@ void pwait(waitq_t* queue) { + // prevent race condition. + cpu_disable_interrupt(); + waitq_t* current_wq = &__current->waitqueue; assert(llist_empty(¤t_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); }