Merge branch 'master' into prog-loader
[lunaix-os.git] / lunaix-os / includes / lunaix / ds / rwlock.h
1 #ifndef __LUNAIX_RWLOCK_H
2 #define __LUNAIX_RWLOCK_H
3
4 #include "mutex.h"
5 #include "waitq.h"
6 #include <stdatomic.h>
7
8 typedef struct rwlock_s
9 {
10     atomic_uint readers;
11     atomic_flag writer;
12     waitq_t waiting_readers;
13     waitq_t waiting_writers;
14 } rwlock_t;
15
16 void
17 rwlock_begin_read(rwlock_t* rwlock);
18
19 void
20 rwlock_end_read(rwlock_t* rwlock);
21
22 void
23 rwlock_begin_write(rwlock_t* rwlock);
24
25 void
26 rwlock_end_write(rwlock_t* rwlock);
27
28 #endif /* __LUNAIX_RWLOCK_H */