pthread_rwlock_init

Initializes a reader-writer lock.

Library:LibC
Classification:POSIX
Service:Synchronization

Syntax

  #include <pthread.h>
   
  int  pthread_rwlock_init  (
     pthread_rwlock_t             *rwlp,
     const pthread_rwlockattr_t   *attr);
  

Parameters

rwlp

(IN) Points to the reader-writer lock to be initialized.

attr

(IN) Points to an attribute structure for reader-writer locks. If NULL, the reader-writer lock is initialized with default attributes, which mark it as private to the process and provide a generic name of "pthread rwlock".

Return Values

If successful, returns zero; otherwise, returns a nonzero error code:

Decimal

Constant

Description

5

ENOMEM

Insufficient memory to complete this call

105

ENOCONTEXT

The calling thread has no context.

Remarks

Once initialized, the reader-writer lock can be used and reused any number of times without being reinitialized.The function initializes the lock in an unlocked state.

Results are undefined if the lock is used without first being intialized or if the function is called specifying an already initialized reader-writer lock.

See Also