summaryrefslogtreecommitdiff
path: root/implement.h
diff options
context:
space:
mode:
authorrpj <rpj>2011-05-06 02:11:50 +0000
committerrpj <rpj>2011-05-06 02:11:50 +0000
commit2fe8aba6a8a4ce09f353f34881c77f93a9c01ca3 (patch)
treefd7f179b1abaa525ec55e34bef23b12f8fd89021 /implement.h
parent941d7cf87c60b55342b51e0b0fcd748589b76167 (diff)
Robust mutexes merged from devel branchpost_merge_with_ROBUST_MUTEXES
Diffstat (limited to 'implement.h')
-rw-r--r--implement.h72
1 files changed, 49 insertions, 23 deletions
diff --git a/implement.h b/implement.h
index b210bc5..8a27fae 100644
--- a/implement.h
+++ b/implement.h
@@ -112,19 +112,24 @@ typedef enum
PThreadStateInitial = 0, /* Thread not running */
PThreadStateRunning, /* Thread alive & kicking */
PThreadStateSuspended, /* Thread alive but suspended */
- PThreadStateCancelPending, /* Thread alive but is */
- /* has cancelation pending. */
+ PThreadStateCancelPending, /* Thread alive but */
+ /* has cancelation pending. */
PThreadStateCanceling, /* Thread alive but is */
- /* in the process of terminating */
- /* due to a cancellation request */
- PThreadStateException, /* Thread alive but exiting */
- /* due to an exception */
- PThreadStateLast
+ /* in the process of terminating */
+ /* due to a cancellation request */
+ PThreadStateExiting, /* Thread alive but exiting */
+ /* due to an exception */
+ PThreadStateLast, /* All handlers have been run and now */
+ /* final cleanup can be done. */
+ PThreadStateReuse /* In reuse pool. */
}
PThreadState;
+typedef struct ptw32_mcs_node_t_ ptw32_mcs_local_node_t;
+typedef struct ptw32_mcs_node_t_* ptw32_mcs_lock_t;
+typedef struct ptw32_robust_node_t_ ptw32_robust_node_t;
+typedef struct ptw32_thread_t_ ptw32_thread_t;
-typedef struct ptw32_thread_t_ ptw32_thread_t;
struct ptw32_thread_t_
{
@@ -141,9 +146,9 @@ struct ptw32_thread_t_
void *parms;
int ptErrno;
int detachState;
- pthread_mutex_t threadLock; /* Used for serialised access to public thread state */
+ ptw32_mcs_lock_t threadLock; /* Used for serialised access to public thread state */
int sched_priority; /* As set, not as currently is */
- pthread_mutex_t cancelLock; /* Used for async-cancel safety */
+ ptw32_mcs_lock_t stateLock; /* Used for async-cancel safety */
int cancelState;
int cancelType;
HANDLE cancelEvent;
@@ -156,6 +161,10 @@ struct ptw32_thread_t_
int implicit:1;
void *keys;
void *nextAssoc;
+ ptw32_mcs_lock_t
+ robustMxListLock; /* robustMxList lock */
+ ptw32_robust_node_t*
+ robustMxList; /* List of currenty held robust mutexes */
};
@@ -215,12 +224,35 @@ struct pthread_mutex_t_
pthread_t ownerThread;
HANDLE event; /* Mutex release notification to waiting
threads. */
+ ptw32_robust_node_t*
+ robustNode; /* Extra state for robust mutexes */
+};
+
+enum ptw32_robust_state_t_
+{
+ PTW32_ROBUST_CONSISTENT,
+ PTW32_ROBUST_INCONSISTENT,
+ PTW32_ROBUST_NOTRECOVERABLE
+};
+
+typedef enum ptw32_robust_state_t_ ptw32_robust_state_t;
+
+/*
+ * Node used to manage per-thread lists of currently-held robust mutexes.
+ */
+struct ptw32_robust_node_t_
+{
+ pthread_mutex_t mx;
+ ptw32_robust_state_t stateInconsistent;
+ ptw32_robust_node_t* prev;
+ ptw32_robust_node_t* next;
};
struct pthread_mutexattr_t_
{
int pshared;
int kind;
+ int robustness;
};
/*
@@ -267,9 +299,6 @@ struct ptw32_mcs_node_t_
successor */
};
-typedef struct ptw32_mcs_node_t_ ptw32_mcs_local_node_t;
-typedef struct ptw32_mcs_node_t_ *ptw32_mcs_lock_t;
-
struct pthread_barrier_t_
{
@@ -277,7 +306,7 @@ struct pthread_barrier_t_
unsigned int nInitialBarrierHeight;
int pshared;
sem_t semBarrierBreeched;
- void * lock; /* MCS lock */
+ ptw32_mcs_lock_t lock;
ptw32_mcs_local_node_t proxynode;
};
@@ -290,7 +319,7 @@ struct pthread_key_t_
{
DWORD key;
void (*destructor) (void *);
- pthread_mutex_t keyLock;
+ ptw32_mcs_lock_t keyLock;
void *threads;
};
@@ -532,6 +561,8 @@ extern pthread_cond_t ptw32_cond_list_tail;
extern int ptw32_mutex_default_kind;
+extern unsigned long long ptw32_threadSeqNumber;
+
extern int ptw32_concurrency;
extern int ptw32_features;
@@ -566,14 +597,9 @@ extern "C"
int ptw32_mutex_check_need_init (pthread_mutex_t * mutex);
int ptw32_rwlock_check_need_init (pthread_rwlock_t * rwlock);
- PTW32_INTERLOCKED_LONG WINAPI
- ptw32_InterlockedCompareExchange (PTW32_INTERLOCKED_LPLONG location,
- PTW32_INTERLOCKED_LONG value,
- PTW32_INTERLOCKED_LONG comparand);
-
- LONG WINAPI
- ptw32_InterlockedExchange (LPLONG location,
- LONG value);
+ int ptw32_robust_mutex_inherit(pthread_mutex_t * mutex);
+ void ptw32_robust_mutex_add(pthread_mutex_t* mutex, pthread_t self);
+ void ptw32_robust_mutex_remove(pthread_mutex_t* mutex, ptw32_thread_t* otp);
DWORD
ptw32_RegisterCancelation (PAPCFUNC callback,