5 * - Reader-Writer Mutex (Multiple Readers, One Writer)
12 typedef struct sRWLock tRWLock;
16 tShortSpinlock Protector; //!< Protector for the lock strucure
17 const char *Name; //!< Human-readable name
18 int Level; // Number of readers active
19 struct sThread *volatile Owner; //!< Owner of the lock (set upon getting the lock)
20 struct sThread *ReaderWaiting; //!< Waiting threads (readers)
21 struct sThread *ReaderWaitingLast; //!< Waiting threads
23 struct sThread *WriterWaiting; //!< Waiting threads (writers)
24 struct sThread *WriterWaitingLast; //!< Waiting threads
28 * \brief Acquire a heavy mutex
29 * \param Mutex Mutex to acquire
30 * \return zero on success, -1 if terminated
32 * This type of mutex checks if the mutex is avaliable, and acquires it
33 * if it is. Otherwise, the current thread is added to the mutex's wait
34 * queue and the thread suspends. When the holder of the mutex completes,
35 * the oldest thread (top thread) on the queue is given the lock and
38 extern int RWLock_AcquireRead(tRWLock *Lock);
40 extern int RWLock_AcquireWrite(tRWLock *LOck);
43 * \brief Release a held mutex
44 * \param Mutex Mutex to release
45 * \note Releasing a non-held mutex has no effect
47 extern void RWLock_Release(tRWLock *Lock);