Simple locking. More...
|Spinlock initializer. |
|#define||spinlock_init(A) *(A) = SPINLOCK_INITIALIZER|
|Initialize a spinlock. |
|Spin on a lock. |
|Free a lock. |
|#define||spinlock_is_locked(A) ( *(A) != 0 )|
|Determine if a lock is locked. |
|typedef volatile int||spinlock_t|
|Spinlock data type. |
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||)||*(A) = SPINLOCK_INITIALIZER|
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|
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||)||( *(A) != 0 )|
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.|
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.|
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.