#include "rwlock.h"
#include "malloc.h"
#include "int.h"
#include "debug.h"
#include "timers.h"
#include "thread.h"
#include "errnums.h"
Functions | |
void | rwlock_init (rwlock_t *rwl) |
void | rwlock_destroy (rwlock_t *rwl) |
Destroy r/w lock. | |
void | rwlock_read_lock (rwlock_t *rwl) |
Lock the r/w lock for reading. | |
void | rwlock_write_lock (rwlock_t *rwl) |
Lock the r/w lock for writing. | |
int | rwlock_read_lock_try (rwlock_t *rwl) |
Non block read lock. | |
int | rwlock_write_lock_try (rwlock_t *rwl) |
Non block write lock. | |
int | rwlock_read_timeout (rwlock_t *rwl, const unsigned int usec) |
Read lock with timeout. | |
int | rwlock_write_timeout (rwlock_t *rwl, const unsigned int usec) |
Write lock with timeout. | |
void | rwlock_read_unlock (rwlock_t *rwl) |
Release r/w lock locked for reading. | |
void | rwlock_write_unlock (rwlock_t *rwl) |
Release r/w lock locked for writing. |
Functions for initialize, destroy, lock for writing or reading and timeout lock. R/w lock can be locked by multiple readers at a time and only one writer at a time. Writers has higher priority, it means that if there are waiting readers and waiting writers the first waiting writer will be woken up and readers will stay suspended. Writing thread can locked the lock recursively and the lock will be free after the count of callings unlock will be same as count of callings lock or lock timeout. This implementation does not test wheter the unlocking thread has the r/w lock locked!
void rwlock_destroy | ( | rwlock_t * | rwl | ) |
Destroy r/w lock.
rwl | - r/w lock structure |
void rwlock_init | ( | rwlock_t * | rwl | ) |
rwl | - r/w lock structure |
void rwlock_read_lock | ( | rwlock_t * | rwl | ) |
Lock the r/w lock for reading.
rwl | - r/w lock structure |
int rwlock_read_lock_try | ( | rwlock_t * | rwl | ) |
Non block read lock.
rwl | - r/w lock structure |
int rwlock_read_timeout | ( | rwlock_t * | rwl, | |
const unsigned int | usec | |||
) |
Read lock with timeout.
rwl | - r/w lock structure | |
usec | - count of microseconds |
void rwlock_read_unlock | ( | rwlock_t * | rwl | ) |
Release r/w lock locked for reading.
rwl | - r/w lock structure |
void rwlock_write_lock | ( | rwlock_t * | rwl | ) |
Lock the r/w lock for writing.
rwl | - r/w lock structure |
int rwlock_write_lock_try | ( | rwlock_t * | rwl | ) |
Non block write lock.
rwl | - r/w lock structure |
int rwlock_write_timeout | ( | rwlock_t * | rwl, | |
const unsigned int | usec | |||
) |
Write lock with timeout.
rwl | - r/w lock structure | |
usec | - count of microseconds |
void rwlock_write_unlock | ( | rwlock_t * | rwl | ) |
Release r/w lock locked for writing.
rwl | - r/w lock structure |