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
* Make the ksym table built-in with kernel image, thus remove the need
[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 0d643d02e7de3649d4da25d50c7b9d41258cc4c1..522974fbcf6b84fc939f2d9f4c55ed1599839638 100644
(file)
--- a/
lunaix-os/kernel/ds/waitq.c
+++ b/
lunaix-os/kernel/ds/waitq.c
@@
-1,18
+1,26
@@
#include <lunaix/ds/waitq.h>
#include <lunaix/process.h>
#include <lunaix/ds/waitq.h>
#include <lunaix/process.h>
+#include <lunaix/sched.h>
#include <lunaix/spike.h>
void
pwait(waitq_t* queue)
{
#include <lunaix/spike.h>
void
pwait(waitq_t* queue)
{
- waitq_t* current_wq = &__current->waitqueue;
+ assert(current_thread);
+ // prevent race condition.
+ cpu_disable_interrupt();
+
+ waitq_t* current_wq = ¤t_thread->waitqueue;
assert(llist_empty(¤t_wq->waiters));
llist_append(&queue->waiters, ¤t_wq->waiters);
assert(llist_empty(¤t_wq->waiters));
llist_append(&queue->waiters, ¤t_wq->waiters);
- // FIXME centralize the state change.
- __current->state = PS_BLOCKED;
- sched_yieldk();
+ block_current_thread();
+ sched_pass();
+
+ // In case of SIGINT-forced awaken
+ llist_delete(¤t_wq->waiters);
+ cpu_enable_interrupt();
}
void
}
void
@@
-23,10
+31,10
@@
pwake_one(waitq_t* queue)
}
waitq_t* wq = list_entry(queue->waiters.next, waitq_t, waiters);
}
waitq_t* wq = list_entry(queue->waiters.next, waitq_t, waiters);
- struct
proc_info* proc = container_of(wq, struct proc_info
, waitqueue);
+ struct
thread* thread = container_of(wq, struct thread
, waitqueue);
- assert(
proc
->state == PS_BLOCKED);
-
proc
->state = PS_READY;
+ assert(
thread
->state == PS_BLOCKED);
+
thread
->state = PS_READY;
llist_delete(&wq->waiters);
}
llist_delete(&wq->waiters);
}
@@
-37,13
+45,14
@@
pwake_all(waitq_t* queue)
return;
}
return;
}
- struct
proc_info* proc
;
+ struct
thread* thread
;
waitq_t *pos, *n;
llist_for_each(pos, n, &queue->waiters, waiters)
{
waitq_t *pos, *n;
llist_for_each(pos, n, &queue->waiters, waiters)
{
-
proc = container_of(pos, struct proc_info
, waitqueue);
+
thread = container_of(pos, struct thread
, waitqueue);
- proc->state = PS_READY;
+ assert(thread->state == PS_BLOCKED);
+ thread->state = PS_READY;
llist_delete(&pos->waiters);
}
}
\ No newline at end of file
llist_delete(&pos->waiters);
}
}
\ No newline at end of file