git://scm.lunaixsky.com
/
lunaix-os.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
feat: (ahci) support multiple AHCI controller
[lunaix-os.git]
/
lunaix-os
/
kernel
/
ds
/
waitq.c
diff --git
a/lunaix-os/kernel/ds/waitq.c
b/lunaix-os/kernel/ds/waitq.c
index 4b5abfd89055024a75bd4f220c808ef9c0b14e33..7045e36731cfc3db8adf5f68d6f099fa2ef244b8 100644
(file)
--- a/
lunaix-os/kernel/ds/waitq.c
+++ b/
lunaix-os/kernel/ds/waitq.c
@@
-5,6
+5,9
@@
void
pwait(waitq_t* queue)
{
void
pwait(waitq_t* queue)
{
+ // prevent race condition.
+ cpu_disable_interrupt();
+
waitq_t* current_wq = &__current->waitqueue;
assert(llist_empty(¤t_wq->waiters));
waitq_t* current_wq = &__current->waitqueue;
assert(llist_empty(¤t_wq->waiters));
@@
-12,6
+15,8
@@
pwait(waitq_t* queue)
block_current();
sched_yieldk();
block_current();
sched_yieldk();
+
+ cpu_enable_interrupt();
}
void
}
void
@@
-42,6
+47,7
@@
pwake_all(waitq_t* queue)
{
proc = container_of(pos, struct proc_info, waitqueue);
{
proc = container_of(pos, struct proc_info, waitqueue);
+ assert(proc->state == PS_BLOCKED);
proc->state = PS_READY;
llist_delete(&pos->waiters);
}
proc->state = PS_READY;
llist_delete(&pos->waiters);
}