refactor: make the demos into dedicated files
[lunaix-os.git] / lunaix-os / kernel / ds / semaphore.c
index 7b059a63d2c1907d0618041da6152edd3de68ff9..ab494d2f3c810469e82d7bfa4bf7e126f576ba2d 100644 (file)
@@ -1,18 +1,24 @@
 #include <lunaix/ds/semaphore.h>
 #include <lunaix/sched.h>
 
-void sem_init(struct sem_t *sem, unsigned int initial) {
+void
+sem_init(struct sem_t* sem, unsigned int initial)
+{
     sem->counter = ATOMIC_VAR_INIT(initial);
 }
 
-void sem_wait(struct sem_t *sem) {
+void
+sem_wait(struct sem_t* sem)
+{
     while (!atomic_load(&sem->counter)) {
         schedule();
     }
     atomic_fetch_sub(&sem->counter, 1);
 }
 
-void sem_post(struct sem_t *sem) {
+void
+sem_post(struct sem_t* sem)
+{
     atomic_fetch_add(&sem->counter, 1);
     // TODO: wake up a thread
 }
\ No newline at end of file