swissChili | 52a03d8 | 2021-07-18 15:22:14 -0700 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <kint.h> |
| 4 | |
| 5 | // Synchronization primitives |
| 6 | |
| 7 | /// Spinlock |
| 8 | typedef volatile int spinlock_t; |
| 9 | |
| 10 | void sl_acquire(spinlock_t *sl); |
| 11 | void sl_release(spinlock_t *sl); |
| 12 | spinlock_t sl_new(); |
| 13 | |
| 14 | /// Semaphore |
| 15 | typedef volatile int semaphore_t; |
| 16 | |
| 17 | void sm_wait(semaphore_t sm); |
| 18 | void sm_signal(semaphore_t sm); |
| 19 | semaphore_t sm_new(); |
| 20 | |
| 21 | /// Initialize synchronization primitives, only call this once after the |
| 22 | /// scheduler has been initialized. |
| 23 | void init_sync(); |