Fix file system racing and ext2 directory insertion (#58)
[lunaix-os.git] / lunaix-os / includes / lunaix / ds / semaphore.h
1 #ifndef __LUNAIX_SEMAPHORE_H
2 #define __LUNAIX_SEMAPHORE_H
3
4 #include <stdatomic.h>
5
6 struct sem_t
7 {
8     atomic_ulong counter;
9     // FUTURE: might need a waiting list
10 };
11
12 void
13 sem_init(struct sem_t* sem, unsigned int initial);
14
15 void
16 sem_wait(struct sem_t* sem);
17
18 void
19 sem_post(struct sem_t* sem);
20
21 #endif /* __LUNAIX_SEMAPHORE_H */