|
ginnOS
The reference: libc, the libraries and the kernel
|
#include "kernel/sync/spinlock.h"#include "arch/arch.h"#include "kernel/assert.h"#include "kernel/cpu/cpu.h"#include "kernel/panic.h"#include "kernel/memory/tlb.h"Macros | |
| #define | SPIN_LIMIT (1u << 28) |
Functions | |
| void | spinlock_init (spinlock_t *lock) |
| initialize a spinlock to the unlocked state. | |
| void | spin_lock (spinlock_t *lock) |
| acquire a lock. | |
| void | spin_unlock (spinlock_t *lock) |
| release a lock that spin_lock() took. | |
| uint32_t | spin_lock_irqsave (spinlock_t *lock) |
| mask interrupts on this core, then acquire a lock. | |
| void | spin_unlock_irqrestore (spinlock_t *lock, uint32_t flags) |
| release a lock and restore the interrupt state captured at acquire time. | |
| bool | spin_is_held (const spinlock_t *lock) |
| check if the core that runs the call holds a lock. | |
| #define SPIN_LIMIT (1u << 28) |
| void spinlock_init | ( | spinlock_t * | lock | ) |
initialize a spinlock to the unlocked state.
| lock | the lock to initialize. |
| void spin_lock | ( | spinlock_t * | lock | ) |
acquire a lock.
it does not change the interrupt state, so interrupts must be masked already (as in Linux's spin_lock in an IRQ handler). pairs with spin_unlock().
| lock | the lock to acquire. |
| void spin_unlock | ( | spinlock_t * | lock | ) |
release a lock that spin_lock() took.
it does not change the interrupt state.
| lock | the lock to release. |
| uint32_t spin_lock_irqsave | ( | spinlock_t * | lock | ) |
mask interrupts on this core, then acquire a lock.
safe to nest: the returned flags carry whether interrupts were enabled on entry. pairs with spin_unlock_irqrestore().
| lock | the lock to acquire. |
| void spin_unlock_irqrestore | ( | spinlock_t * | lock, |
| uint32_t | flags ) |
release a lock and restore the interrupt state captured at acquire time.
pairs with spin_lock_irqsave().
| lock | the lock to release. |
| flags | the value returned by spin_lock_irqsave(). |
| bool spin_is_held | ( | const spinlock_t * | lock | ) |
check if the core that runs the call holds a lock.
for assertions.
| lock | the lock to check. |