16#include <minix/sys_config.h>
19#if defined(__i386__) || defined(__x86_64__)
20#include "arch/i386/include/arch_cpu.h"
41#define MAX_SPIN_THRESHOLD 100000
43#ifndef KERNEL_YIELD_DEFINED
44#define KERNEL_YIELD_DEFINED
127 if (__sync_lock_test_and_set(&lock->
locked, 1) == 0) {
143 while (lock->
locked != 0) {
166 if (__sync_lock_test_and_set(&lock->
locked, 1) == 0) {
191 __sync_lock_release(&lock->
locked);
static void kernel_yield(void)
Yields the CPU, typically to the scheduler. (Stub Implementation)
Definition k_spinlock.h:57
static void simple_spin_init(simple_spinlock_t *lock)
Initializes a spinlock to the unlocked state and resets statistics.
Definition k_spinlock.h:104
static void arch_pause(void)
Placeholder for arch_pause on non-x86 architectures.
Definition k_spinlock.h:29
static void simple_spin_lock(simple_spinlock_t *lock)
Acquires a spinlock, busy-waiting if necessary.
Definition k_spinlock.h:123
#define MAX_SPIN_THRESHOLD
Maximum number of spin iterations before attempting to yield.
Definition k_spinlock.h:41
static void simple_spin_unlock(simple_spinlock_t *lock)
Releases a previously acquired spinlock.
Definition k_spinlock.h:184
Structure representing a simple spinlock.
Definition k_spinlock.h:77
unsigned long contentions
Number of times a thread tried to acquire the lock but found it already held, thus entering a spin-wa...
Definition k_spinlock.h:91
unsigned long acquisitions
Number of times the lock was successfully acquired.
Definition k_spinlock.h:88
volatile int locked
The lock state. 0 for unlocked, 1 for locked.
Definition k_spinlock.h:86