AquilaOS documentation
How it works, and its code
Loading...
Searching...
No Matches
lock.h
Go to the documentation of this file.
1#ifndef _SYS_LOCK_H
2#define _SYS_LOCK_H
3
4/*
5 * The kernel lock (sys/lock.c): only one CPU at a time runs the kernel.
6 * See docs/kernel/smp.md.
7 */
8
9/* Takes and lets go of the lock; says whether this CPU holds it. */
10void kernel_lock(void);
11void kernel_unlock(void);
12int kernel_lock_held(void);
13
14/* For an interrupt or an exception: kernel_enter() takes the lock unless
15 * this CPU holds it already (it came from the kernel), and returns 1 if it
16 * took it; kernel_leave() then lets go of it on the way out. */
17int kernel_enter(void);
18void kernel_leave(int took);
19
23void arch_lock_spin(void);
24
27void arch_lock_taken(void);
28
29#endif /* ! _SYS_LOCK_H */
void arch_lock_spin(void)
Runs in the kernel lock's wait loop, on each turn.
Definition smp.c:20
void arch_lock_taken(void)
Runs once this CPU has taken the kernel lock.
Definition smp.c:25
void kernel_unlock(void)
Lets go of the kernel lock, for the next CPU waiting for it.
Definition lock.c:46
int kernel_lock_held(void)
Says whether this CPU holds the kernel lock.
Definition lock.c:57
void kernel_lock(void)
Takes the kernel lock, waiting for its turn if another CPU holds it.
Definition lock.c:32
void kernel_leave(int took)
Lets go of the kernel lock on leaving the kernel, if kernel_enter() took it.
Definition lock.c:83
int kernel_enter(void)
Takes the kernel lock on entering the kernel, unless this CPU holds it already (an exception inside t...
Definition lock.c:68