|
miniOS
x86_64 hobby kernel with SMP, VFS, and POSIX process model
|
FIFO ticket spinlock with IRQ-safe variants. More...
Classes | |
| struct | spinlock_t |
Macros | |
| #define | SPINLOCK_INIT { .counter = 0 } |
Functions | |
| 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) |
FIFO ticket spinlock with IRQ-safe variants.
Provides a 16-bit ticket spinlock (spinlock_t) and four operations:
| #define SPINLOCK_INIT { .counter = 0 } |
SPINLOCK_INIT — static initialiser; produces a free (unlocked) spinlock.
| void spinlock_irq | ( | spinlock_t * | lock | ) |
spinlock_irq() - Unconditionally disable IRQs then acquire spinlock. @lock: Spinlock to acquire.
Use only when caller is certain IRQs were enabled (no RFLAGS save needed). Paired with spinlock_irq_unlock().

| void spinlock_irq_unlock | ( | spinlock_t * | lock | ) |
spinlock_irq_unlock() - Release spinlock and unconditionally re-enable IRQs. @lock: Spinlock to release. Must have been acquired via spinlock_irq().

| void spinlock_irqrestore | ( | spinlock_t * | lock, |
| unsigned long | flags ) |
spinlock_irqrestore() - Release spinlock and restore interrupt state. @lock: Spinlock to release. Must have been acquired via spinlock_irqsave. @flags: Saved RFLAGS from spinlock_irqsave (restored as-is; re-enables IRQs if they were enabled before the matching spinlock_irqsave call).


| void spinlock_irqsave | ( | spinlock_t * | lock, |
| unsigned long * | flags ) |
spinlock_irqsave() - Save interrupt state, disable IRQs, then acquire. @lock: Spinlock to acquire. @flags: Output — saved RFLAGS value (pass to spinlock_irqrestore).
Use in any code path reachable from both normal context and LAPIC timer ISR. Prevents ISR re-entering the same lock while the lock is held.


| void spinlock_lock | ( | spinlock_t * | lock | ) |
spinlock_lock() - Acquire the spinlock (spin until free). @lock: Spinlock to acquire.
Atomically claims a ticket (incrementing next) and spins with PAUSE hint until owner reaches that ticket. FIFO order guaranteed. Do NOT call from ISR context (use spinlock_irqsave instead).


| void spinlock_unlock | ( | spinlock_t * | lock | ) |
spinlock_unlock() - Release the spinlock. @lock: Spinlock to release. Must be held by the calling CPU.
Atomically increments the owner field, handing the lock to the next waiter.

