SyncRWLock() , SyncRWLock_r()
QNX SDP8.0C Library ReferenceAPIDeveloper
Lock or unlock a read-write lock
Note: 
    Don't use the SyncRWLock() or SyncRWLock_r() kernel call directly; instead, use the
    POSIX functions for read-write locks.
  
Synopsis:
#include <sys/neutrino.h>
int SyncRWLock( sync_t * sync, unsigned op);
int SyncRWLock_r( sync_t * sync, unsigned op);
Arguments:
- sync
 - A pointer to a pthread_rwlock_t object that you want to lock for writing.
 - op
 - The operation type; one of:
    
- _NTO_RWLOCK_READ_LOCK — acquire the lock as a reader.
 - _NTO_RWLOCK_READ_TRYLOCK — attempt to acquire the lock as a reader, but return immediately if the lock is busy.
 - _NTO_RWLOCK_READ_UNLOCK — release the lock as a reader.
 - _NTO_RWLOCK_WRITE_LOCK — acquire the lock as a writer.
 - _NTO_RWLOCK_WRITE_TRYLOCK — attempt to acquire the lock as a writer, but return immediately if the lock is busy.
 - _NTO_RWLOCK_WRITE_UNLOCK — release the lock as a writer.
 
 
Library:
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
Description:
 The SyncRWLock() and SyncRWLock_r() kernel calls lock or unlock
  a read-write lock. These kernel calls work on the given sync_t object and perform the action specified
  by the operation argument op.
  
Note: 
Writers and readers are sorted in equal priority, with no preference given to writers, based on the order of their arrival.
Blocking states
- STATE_RWLOCK_READ
 - The calling thread blocks waiting for a write-lock to be unlocked.
 - STATE_RWLOCK_WRITE
 - The calling thread blocks waiting for all read-locks to be unlocked.
 
Returns:
The only difference between these functions is the way they indicate errors:
- SyncRWLock()
 - If an error occurs, the function returns -1 and sets errno. Returns 0 on success.
 - SyncRWLock_r()
 - Returns EOK on success. This function does NOT set errno. If an error occurs, this function returns any value listed in the Errors section.
 
Errors:
- EAGAIN
 - Couldn't acquire read lock because the maximum number of read locks would be exceeded.
 - EBUSY
 - One of the following occurred:
    
- An _NTO_RWLOCK_READ_TRYLOCK operation found the object write-locked.
 - An _NTO_RWLOCK_WRITE_TRYLOCK operation found the object already locked.
 
 - EDEADLK
 - The calling thread already has a write lock.
 - EFAULT
 - A fault occurred when the kernel tried to access the sync memory provided.
 - EINTR
 - A signal was received while waiting for the lock.
 - EINVAL
 - The read-write lock is invalid.
 - EPERM
 - An _NTO_RWLOCK_WRITE_UNLOCK attempted to release a write-lock held by another thread.
 - ETIMEDOUT
 - The lock couldn't be acquired before the specified timeout expired.
 
Classification:
| Safety: | |
|---|---|
| Cancellation point | No | 
| Signal handler | Yes | 
| Thread | Yes | 
Page updated: 
