OpenMPI 0.1.1

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

mutex.h
1 /*
2 * Copyright (c) 2010 Cisco Systems, Inc. All rights reserved.
3 *
4 * $COPYRIGHT$
5 *
6 * Additional copyrights may follow
7 *
8 * $HEADER$
9 */
10
11 #ifndef ORTE_MUTEX_H
12 #define ORTE_MUTEX_H
13
14 #include "orte_config.h"
15
16 #include "opal/sys/atomic.h"
17 #include "opal/threads/mutex.h"
18 #if OPAL_ENABLE_DEBUG
19 #include "opal/util/output.h"
20 #endif
21
22 BEGIN_C_DECLS
23
24 /* Lock a mutex */
25 #define ORTE_THREAD_LOCK(mutex) opal_mutex_lock(mutex)
26
27 /**
28 * Try to lock a mutex
29 * Returns 0 if mutex was locked, non-zero otherwise.
30 */
31 #define ORTE_THREAD_TRYLOCK(mutex) opal_mutex_trylock(mutex)
32
33 /** Unlock a mutex */
34 #define ORTE_THREAD_UNLOCK(mutex) opal_mutex_unlock(mutex)
35
36
37 /* Lock a mutex */
38 #define ORTE_THREAD_SCOPED_LOCK(mutex, action) \
39 do { \
40 opal_mutex_lock(mutex); \
41 (action); \
42 opal_mutex_unlock(mutex); \
43 } while (0)
44
45 /* Use an atomic operation for increment/decrement */
46
47 #define ORTE_THREAD_ADD32(x,y) opal_atomic_add_32(x,y)
48
49 #define ORTE_THREAD_ADD64(x,y) opal_atomic_add_64(x,y)
50
51 #define ORTE_THREAD_ADD_SIZE_T(x,y) opal_atomic_add_size_t(x,y)
52
53 #define ORTE_CMPSET(x, y, z) ((*(x) == (y)) ? ((*(x) = (z)), 1) : 0)
54
55 #if OPAL_HAVE_ATOMIC_CMPSET_32
56 #define ORTE_ATOMIC_CMPSET_32(x, y, z) opal_atomic_cmpset_32(x, y, z)
57 # endif
58
59 # if OPAL_HAVE_ATOMIC_CMPSET_64
60 #define ORTE_ATOMIC_CMPSET_64(x, y, z) opal_atomic_cmpset_64(x, y, z)
61 #endif
62
63 #if OPAL_HAVE_ATOMIC_CMPSET_32 || OPAL_HAVE_ATOMIC_CMPSET_64
64 #define ORTE_ATOMIC_CMPSET(x, y, z) opal_atomic_cmpset(x, y, z)
65 #endif
66
67 END_C_DECLS
68
69 #endif /* ORTE_MUTEX_H */
output.h
OPAL output stream facility.
atomic.h
Atomic operations.
mutex.h
Mutual exclusion functions.