AquilaOS documentation
How it works, and its code
Loading...
Searching...
No Matches
lock.h File Reference

Go to the source code of this file.

Functions

void kernel_lock (void)
 Takes the kernel lock, waiting for its turn if another CPU holds it.
void kernel_unlock (void)
 Lets go of the kernel lock, for the next CPU waiting for it.
int kernel_lock_held (void)
 Says whether this CPU holds the kernel lock.
int kernel_enter (void)
 Takes the kernel lock on entering the kernel, unless this CPU holds it already (an exception inside the kernel).
void kernel_leave (int took)
 Lets go of the kernel lock on leaving the kernel, if kernel_enter() took it.
void arch_lock_spin (void)
 Runs in the kernel lock's wait loop, on each turn.
void arch_lock_taken (void)
 Runs once this CPU has taken the kernel lock.

Function Documentation

◆ arch_lock_spin()

void arch_lock_spin ( void )

Runs in the kernel lock's wait loop, on each turn.

The architecture answers the requests that the lock's holder makes of the other CPUs (a TLB flush), which can't wait until the lock is free.

Definition at line 20 of file smp.c.

References arch_lock_spin(), and x86_tlb_ipi().

Referenced by arch_lock_spin(), and kernel_lock().

◆ arch_lock_taken()

void arch_lock_taken ( void )

Runs once this CPU has taken the kernel lock.

The architecture catches up with what changed while it waited (the kernel's mappings).

Definition at line 25 of file smp.c.

References cpu::arch, arch_lock_taken(), arch_cpu::kernel_gen, kernel_gen, and tlb_flush().

Referenced by arch_lock_taken(), and kernel_lock().

◆ kernel_enter()

int kernel_enter ( void )

Takes the kernel lock on entering the kernel, unless this CPU holds it already (an exception inside the kernel).

Returns
1 if it took the lock, for kernel_leave(), or 0

Definition at line 68 of file lock.c.

References kernel_enter(), kernel_lock(), and kernel_lock_held().

Referenced by __x86_irq_handler(), __x86_isr(), aarch64_irq(), aarch64_sync(), and kernel_enter().

◆ kernel_leave()

void kernel_leave ( int took)

Lets go of the kernel lock on leaving the kernel, if kernel_enter() took it.

Parameters
tookwhat kernel_enter() returned

Definition at line 83 of file lock.c.

References kernel_leave(), and kernel_unlock().

Referenced by __x86_irq_handler(), __x86_isr(), aarch64_irq(), aarch64_sync(), and kernel_leave().

◆ kernel_lock()

void kernel_lock ( void )

Takes the kernel lock, waiting for its turn if another CPU holds it.

Definition at line 32 of file lock.c.

References arch_lock_spin(), arch_lock_taken(), kernel_lock(), next_ticket, owner, and serving.

Referenced by aarch64_init(), kernel_enter(), kernel_lock(), and x86_cpu_init().

◆ kernel_lock_held()

int kernel_lock_held ( void )

Says whether this CPU holds the kernel lock.

Returns
1 if it does, 0 if not

Definition at line 57 of file lock.c.

References kernel_lock_held(), and owner.

Referenced by __arch_idle(), kernel_enter(), and kernel_lock_held().

◆ kernel_unlock()

void kernel_unlock ( void )

Lets go of the kernel lock, for the next CPU waiting for it.

Definition at line 46 of file lock.c.

References kernel_unlock(), owner, and serving.

Referenced by __arch_idle(), kernel_leave(), kernel_unlock(), and thread_spawn().