A Readers writer lock allows concurrent access for readers and exclusionary access for writers.
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] | newrwlock | handle to a new rwlock |
- Returns
- Error code
- Return values
-
Definition at line 26 of file rwlock.c.
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] | rwlock | handle to the rwlock |
- Returns
- Error code
- Return values
-
Definition at line 59 of file rwlock.c.
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] | rwlock | handle to the rwlock |
- Returns
- Error code
- Return values
-
Definition at line 98 of file rwlock.c.
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] | rwlock | handle to the rwlock |
- Returns
- Error code
- Return values
-
Definition at line 162 of file rwlock.c.
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] | rwlock | handle to the rwlock |
- Returns
- Error code
- Return values
-
Definition at line 132 of file rwlock.c.