0.3.1
Synchronization

Typedefs

typedef uint8_t cpu_sync_lock_t
 An 8-bit integer value representing the lock index in the BIOS lock array.
 

Functions

static bool cpu_sync_mutex (cpu_sync_lock_t b)
 Provide functionality of mutual exclusion.
 
static void cpu_sync_mutex_clear (cpu_sync_lock_t b)
 Clear the lock.
 
static void cpu_sync_spinlock (cpu_sync_lock_t b)
 Provide functionality of a spinlock.
 
static void cpu_sync_spinlock_clear (cpu_sync_lock_t b)
 Clear the lock.
 

Detailed Description

Description goes here.

Typedef Documentation

◆ cpu_sync_lock_t

An 8-bit integer value representing the lock index in the BIOS lock array.

All functions, otherwise noted make use of an exclusive area in the first 0x4000 bytes of HWRAM for all the lock variables. The size of the "lock array" is 256 bytes, and each lock variable is 1-byte.

For the lock array, the user is responsible for keeping track of usage. There is no way to determine which locks are being used.

Function Documentation

◆ cpu_sync_mutex()

static bool cpu_sync_mutex ( cpu_sync_lock_t  b)
inlinestatic

Provide functionality of mutual exclusion.

Implementation of the mutex is using test-and-set CPU instruction tas.b.

Parameters
bThe lock index in the lock array.
Returns
true if locking was previously unlocked, otherwise false.

◆ cpu_sync_mutex_clear()

static void cpu_sync_mutex_clear ( cpu_sync_lock_t  b)
inlinestatic

Clear the lock.

Warning
The clearing of b is not atomic.
Parameters
bThe lock index in the lock array.

◆ cpu_sync_spinlock()

static void cpu_sync_spinlock ( cpu_sync_lock_t  b)
inlinestatic

Provide functionality of a spinlock.

Busy wait in a loop while repeatedly checking if the b is available.

Parameters
bThe lock index in the lock array.

◆ cpu_sync_spinlock_clear()

static void cpu_sync_spinlock_clear ( cpu_sync_lock_t  b)
inlinestatic

Clear the lock.

Warning
The clearing of b is not atomic.
Parameters
bThe lock index in the lock array.