#include <synch.h> (or #include <thread.h>) int rwlock_init(rwlock_t *rwlp, int type, void * arg);
type can be one of the following values:
USYNC_PROCESS The read-write lock can be used to synchronize threads in this process and other processes. arg is ignored.
USYNC_THREAD The read-write lock can be used to synchronize threads in this process only. arg is ignored.
Multiple threads must not initialize the same read-write lock simultaneously. Read-write locks can also be initialized by allocation in zeroed memory, in which case a type of USYNC_THREAD is assumed. A read-write lock must not be reinitialized while other threads might be using the lock.
For POSIX threads, see pthread_rwlock_init Syntax .
#include <thread.h> rwlock_t rwlp; int ret; /* to be used within this process only */ ret = rwlock_init(&rwlp, USYNC_THREAD, 0);
#include <thread.h> rwlock_t rwlp; int ret; /* to be used among all processes */ ret = rwlock_init(&rwlp, USYNC_PROCESS, 0);