diff options
Diffstat (limited to 'src/include/smp_sync.h')
-rw-r--r-- | src/include/smp_sync.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/include/smp_sync.h b/src/include/smp_sync.h new file mode 100644 index 0000000..92784b8 --- /dev/null +++ b/src/include/smp_sync.h @@ -0,0 +1,17 @@ +#ifndef SMP_SYNC_INCLUDED +#define SMP_SYNC_INCLUDED + +static inline void lock(uint8_t *lock) { + asm("mov al, 1\n" + "spinlock:\n" + "lock xchgb [%0], al\n" + "test al, al\n" + "jnz spinlock\n" + ::"r"(lock):"al"); +} + +static inline void unlock(uint8_t *lock) { + asm("lock andb [%0], 0"::"r"(lock)); +} + +#endif |