|
miniOS
x86_64 hobby kernel with SMP, VFS, and POSIX process model
|
#include <miniOS/arch/x86_64/spinlock.h>
Functions | |
| static uint16_t | atomic_xadd_u16 (volatile uint16_t *ptr, uint16_t val) |
| static void | atomic_inc_u8_low (volatile uint16_t *ptr) |
| static void | save_flags_and_cli (unsigned long *flags) |
| static void | restore_flags (unsigned long flags) |
| void | spinlock_lock (spinlock_t *lock) |
| void | spinlock_unlock (spinlock_t *lock) |
| void | spinlock_irqsave (spinlock_t *lock, unsigned long *flags) |
| void | spinlock_irqrestore (spinlock_t *lock, unsigned long flags) |
| void | spinlock_irq (spinlock_t *lock) |
| void | spinlock_irq_unlock (spinlock_t *lock) |
|
inlinestatic |
atomic_inc_u8_low — atomically increment low byte of *ptr (owner field). Must NOT use incw: incw increments the full 16-bit value, so when the owner byte overflows 0xFF→0x00 the carry corrupts the next-ticket byte. incb on the low byte increments only bits [7:0] without carry.

atomic_xadd_u16 — atomically: tmp = *ptr; *ptr += val; return tmp

|
inlinestatic |
restore_flags — push saved value onto stack, popf restores RFLAGS.IF

|
inlinestatic |
save_flags_and_cli — push RFLAGS to *flags, then cli
