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: experimental tty console with scrollback buffer.
[lunaix-os.git]
/
lunaix-os
/
kernel
/
ds
/
semaphore.c
diff --git
a/lunaix-os/kernel/ds/semaphore.c
b/lunaix-os/kernel/ds/semaphore.c
index 21d0e3399d761f3aaf2d3528a83dd55187144143..7b059a63d2c1907d0618041da6152edd3de68ff9 100644
(file)
--- a/
lunaix-os/kernel/ds/semaphore.c
+++ b/
lunaix-os/kernel/ds/semaphore.c
@@
-1,4
+1,5
@@
#include <lunaix/ds/semaphore.h>
#include <lunaix/ds/semaphore.h>
+#include <lunaix/sched.h>
void sem_init(struct sem_t *sem, unsigned int initial) {
sem->counter = ATOMIC_VAR_INIT(initial);
void sem_init(struct sem_t *sem, unsigned int initial) {
sem->counter = ATOMIC_VAR_INIT(initial);
@@
-6,7
+7,7
@@
void sem_init(struct sem_t *sem, unsigned int initial) {
void sem_wait(struct sem_t *sem) {
while (!atomic_load(&sem->counter)) {
void sem_wait(struct sem_t *sem) {
while (!atomic_load(&sem->counter)) {
- // TODO: yield the cpu
+ schedule();
}
atomic_fetch_sub(&sem->counter, 1);
}
}
atomic_fetch_sub(&sem->counter, 1);
}