prg_mt_mutex_create()
Abstract
Creates a mutex object to serialize access to shared resources in a parallel environment.
Syntax
prg_mt_mutex_create (options, rank, description, result_ptr)
| Argument | Type | Description |
|---|---|---|
options |
int |
One of the following: • PRGC_MT_MUTEX_NO_OPTIONS: base mutex• PRGC_MT_MUTEX_RECURSIVE: recursive mutex• PRGC_MT_MUTEX_READER_WRITER: reader/writer mutex potentially OR'ed (C's |) with PRGC_MT_MUTEX_RANK_CHECK: use rank info to prevent locks if badly ordered, PRGC_MT_MUTEX_LOCK_ID_TRACK: keep track of the process ID for error reporting |
rank |
int |
rank of the mutex, ignored unless PRGC_MT_MUTEX_RANK_CHECK is part of the options |
description |
const char * |
human-readable description used in error messages generated by the prg_mt package |
result_ptr |
PrtT_Mutex_Result |
optional storage space for result value (no value is provided if this is set to PRGC_NIL) |
Return Type
PrgT_Mutex *
Resulting mutex object, or PRGC_NIL if creation failed.
Header
prg_mt.h
Details
This function allows you to create one of the mutex forms described in Package Overview. The resulting object should be used with prg_mt_mutex_lock() and prg_mt_mutex_unlock() to correctly access a shared resource.
Each shared resource should have its own mutex if possible.