KallistiOS git master
Independent SDK for the Sega Dreamcast
|
Simple locking. More...
Go to the source code of this file.
Macros | |
#define | SPINLOCK_INITIALIZER 0 |
Spinlock initializer. | |
#define | spinlock_init(A) |
Initialize a spinlock. | |
#define | spinlock_lock(A) |
Spin on a lock. | |
#define | spinlock_trylock(A) |
Try to lock, without spinning. | |
#define | spinlock_unlock(A) |
Free a lock. | |
#define | spinlock_is_locked(A) |
Determine if a lock is locked. | |
Typedefs | |
typedef volatile int | spinlock_t |
Spinlock data type. | |
Simple locking.
This file contains definitions for very simple locks. Most of the time, you will probably not use such low-level locking, but will opt for something more fully featured like mutexes, semaphores, reader-writer semaphores, or recursive locks.
#define spinlock_init | ( | A | ) |
Initialize a spinlock.
This function-like macro abstracts initializing a spinlock, in case the initializer is not applicable to what you are doing.
A | A pointer to the spinlock to be initialized. |
#define SPINLOCK_INITIALIZER 0 |
Spinlock initializer.
All created spinlocks should be initialized with this initializer so that they are in a sane state, ready to be used.
#define spinlock_is_locked | ( | A | ) |
Determine if a lock is locked.
This macro will return whether or not the lock specified is actually locked when it is called. This is NOT a thread-safe way of determining if a lock will be locked when you get around to locking it!
A | A pointer to the spinlock to be checked. |
#define spinlock_lock | ( | A | ) |
Spin on a lock.
This macro will spin on the lock, and will not return until the lock has been obtained for the calling thread.
A | A pointer to the spinlock to be locked. |
#define spinlock_trylock | ( | A | ) |
Try to lock, without spinning.
This macro will attempt to lock the lock, but will not spin. Instead, it will return whether the lock was obtained or not.
A | A pointer to the spinlock to be locked. |
#define spinlock_unlock | ( | A | ) |
Free a lock.
This macro will unlock the lock that is currently held by the calling thread. Do not use this macro unless you actually hold the lock!
A | A pointer to the spinlock to be unlocked. |
typedef volatile int spinlock_t |
Spinlock data type.