ARGOBOTS
Functions
Readers Writer Lock

Functions

int ABT_rwlock_create (ABT_rwlock *newrwlock)
 Create a new rwlock ABT_rwlock_create creates a new rwlock object and returns its handle through newrwlock. If an error occurs in this routine, a non-zero error code will be returned and newrwlock will be set to ABT_RWLOCK_NULL. More...
 
int ABT_rwlock_free (ABT_rwlock *rwlock)
 Free the rwlock object. More...
 
int ABT_rwlock_rdlock (ABT_rwlock rwlock)
 Lock the rwlock as a reader. More...
 
int ABT_rwlock_wrlock (ABT_rwlock rwlock)
 Lock the rwlock as a writer. More...
 
int ABT_rwlock_unlock (ABT_rwlock rwlock)
 Unlock the rwlock. More...
 

Detailed Description

A Readers writer lock allows concurrent access for readers and exclusionary access for writers.

Function Documentation

int ABT_rwlock_create ( ABT_rwlock newrwlock)

Create a new rwlock ABT_rwlock_create creates a new rwlock object and returns its handle through newrwlock. If an error occurs in this routine, a non-zero error code will be returned and newrwlock will be set to ABT_RWLOCK_NULL.

Only ULTs can use the rwlock, and tasklets must not use it.

Parameters
[out]newrwlockhandle to a new rwlock
Returns
Error code
Return values
ABT_SUCCESSon success

Definition at line 26 of file rwlock.c.

int ABT_rwlock_free ( ABT_rwlock rwlock)

Free the rwlock object.

ABT_rwlock_free deallocates the memory used for the rwlock object associated with the handle rwlock. If it is successfully processed, rwlock is set to ABT_RWLOCK_NULL.

Using the rwlock handle after calling ABT_rwlock_free may cause undefined behavior.

Parameters
[in,out]rwlockhandle to the rwlock
Returns
Error code
Return values
ABT_SUCCESSon success

Definition at line 59 of file rwlock.c.

int ABT_rwlock_rdlock ( ABT_rwlock  rwlock)

Lock the rwlock as a reader.

ABT_rwlock_rdlock locks the rwlock rwlock. If this routine successfully returns, the caller ULT acquires the rwlock. If the rwlock has been locked by a writer, the caller ULT will be blocked until the rwlock becomes available. rwlocks may be acquired by any number of readers concurrently. When the caller ULT is blocked, the context is switched to the scheduler of the associated ES to make progress of other work units.

The rwlock can be used only by ULTs. Tasklets must not call any blocking routines like ABT_rwlock_rdlock.

Parameters
[in]rwlockhandle to the rwlock
Returns
Error code
Return values
ABT_SUCCESSon success

Definition at line 98 of file rwlock.c.

int ABT_rwlock_unlock ( ABT_rwlock  rwlock)

Unlock the rwlock.

ABT_rwlock_unlock unlocks the rwlock rwlock. If the caller ULT locked the rwlock, this routine unlocks the rwlock. However, if the caller ULT did not lock the rwlock, this routine may result in undefined behavior.

Parameters
[in]rwlockhandle to the rwlock
Returns
Error code
Return values
ABT_SUCCESSon success

Definition at line 162 of file rwlock.c.

int ABT_rwlock_wrlock ( ABT_rwlock  rwlock)

Lock the rwlock as a writer.

ABT_rwlock_wrlock locks the rwlock rwlock. If this routine successfully returns, the caller ULT acquires the rwlock. If the rwlock has been locked by a reader or a writer, the caller ULT will be blocked until the rwlock becomes available. When the caller ULT is blocked, the context is switched to the scheduler of the associated ES to make progress of other work units.

The rwlock can be used only by ULTs. Tasklets must not call any blocking routines like ABT_rwlock_wrlock.

Parameters
[in]rwlockhandle to the rwlock
Returns
Error code
Return values
ABT_SUCCESSon success

Definition at line 132 of file rwlock.c.