summaryrefslogtreecommitdiff
path: root/implement.h
diff options
context:
space:
mode:
authorrpj <rpj>2010-06-20 03:31:18 +0000
committerrpj <rpj>2010-06-20 03:31:18 +0000
commita3ea0b24409b89bd08c0a2268dbae834724734df (patch)
tree4629fd085756226f0cee8beba4faf66466ef0410 /implement.h
parent135d6f060c5e5232311af77bd0d0f500e861290c (diff)
See ChangeLogs: preparing for new release.
Diffstat (limited to 'implement.h')
-rw-r--r--implement.h89
1 files changed, 37 insertions, 52 deletions
diff --git a/implement.h b/implement.h
index 69930ef..00f153f 100644
--- a/implement.h
+++ b/implement.h
@@ -11,7 +11,7 @@
* Copyright(C) 1998 John E. Bossom
* Copyright(C) 1999,2005 Pthreads-win32 contributors
*
- * Contact Email: rpj@callisto.canberra.edu.au
+ * Contact Email: Ross.Johnson@homemail.com.au
*
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
@@ -151,9 +151,6 @@ struct ptw32_thread_t_
int implicit:1;
void *keys;
void *nextAssoc;
-#ifdef _POSIX_CXX09_EXTENSIONS
- int refs; /* C++ Thread Support Library extension */
-#endif
};
@@ -252,13 +249,31 @@ struct pthread_spinlock_t_
} u;
};
+/*
+ * MCS lock queue node - see ptw32_MCS_lock.c
+ */
+struct ptw32_mcs_node_t_
+{
+ struct ptw32_mcs_node_t_ **lock; /* ptr to tail of queue */
+ struct ptw32_mcs_node_t_ *next; /* ptr to successor in queue */
+ LONG readyFlag; /* set after lock is released by
+ predecessor */
+ LONG nextFlag; /* set after 'next' ptr is set by
+ 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_
{
unsigned int nCurrentBarrierHeight;
unsigned int nInitialBarrierHeight;
- int iStep;
int pshared;
- sem_t semBarrierBreeched[2];
+ sem_t semBarrierBreeched;
+ void * lock; /* MCS lock */
+ ptw32_mcs_local_node_t proxynode;
};
struct pthread_barrierattr_t_
@@ -276,7 +291,6 @@ struct pthread_key_t_
typedef struct ThreadParms ThreadParms;
-typedef struct ThreadKeyAssoc ThreadKeyAssoc;
struct ThreadParms
{
@@ -327,22 +341,7 @@ struct pthread_rwlockattr_t_
int pshared;
};
-/*
- * MCS lock queue node - see ptw32_MCS_lock.c
- */
-struct ptw32_mcs_node_t_
-{
- struct ptw32_mcs_node_t_ **lock; /* ptr to tail of queue */
- struct ptw32_mcs_node_t_ *next; /* ptr to successor in queue */
- LONG readyFlag; /* set after lock is released by
- predecessor */
- LONG nextFlag; /* set after 'next' ptr is set by
- successor */
-};
-
-typedef struct ptw32_mcs_node_t_ ptw32_mcs_local_node_t;
-typedef struct ptw32_mcs_node_t_ *ptw32_mcs_lock_t;
-
+typedef struct ThreadKeyAssoc ThreadKeyAssoc;
struct ThreadKeyAssoc
{
@@ -380,17 +379,16 @@ struct ThreadKeyAssoc
* general lock (guarding the row) and the thread's general
* lock (guarding the column). This avoids the need for a
* dedicated lock for each association, which not only consumes
- * more handles but requires that: before the lock handle can
- * be released - both the key must be deleted and the thread
- * must have called the destructor. The two-lock arrangement
- * allows the resources to be freed as soon as either thread or
- * key is concluded.
+ * more handles but requires that the lock resources persist
+ * until both the key is deleted and the thread has called the
+ * destructor. The two-lock arrangement allows those resources
+ * to be freed as soon as either thread or key is concluded.
*
- * To avoid deadlock: whenever both locks are required, the key
- * and thread locks are always acquired in the order: key lock
- * then thread lock. An exception to this exists when a thread
- * calls the destructors, however this is done carefully to
- * avoid deadlock.
+ * To avoid deadlock, whenever both locks are required both the
+ * key and thread locks are acquired consistently in the order
+ * "key lock then thread lock". An exception to this exists
+ * when a thread calls the destructors, however, this is done
+ * carefully (but inelegantly) to avoid deadlock.
*
* An association is created when a thread first calls
* pthread_setspecific() on a key that has a specified
@@ -424,7 +422,7 @@ struct ThreadKeyAssoc
*
* nextThread
* The pthread_key_t->threads attribute is the head of
- * a chain of assoctiations that runs through the
+ * a chain of associations that runs through the
* nextThreads link. This chain provides the 1 to many
* relationship between a pthread_key_t and all the
* PThreads that have called pthread_setspecific for
@@ -460,7 +458,7 @@ struct ThreadKeyAssoc
* This macro constructs a software exception code following
* the same format as the standard Win32 error codes as defined
* in WINERROR.H
- * Values are 32 bit values layed out as follows:
+ * Values are 32 bit values laid out as follows:
*
* 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
* +---+-+-+-----------------------+-------------------------------+
@@ -569,7 +567,6 @@ extern "C"
int ptw32_cond_check_need_init (pthread_cond_t * cond);
int ptw32_mutex_check_need_init (pthread_mutex_t * mutex);
int ptw32_rwlock_check_need_init (pthread_rwlock_t * rwlock);
- int ptw32_spinlock_check_need_init (pthread_spinlock_t * spinlock);
PTW32_INTERLOCKED_LONG WINAPI
ptw32_InterlockedCompareExchange (PTW32_INTERLOCKED_LPLONG location,
@@ -623,8 +620,12 @@ extern "C"
void ptw32_mcs_lock_acquire (ptw32_mcs_lock_t * lock, ptw32_mcs_local_node_t * node);
+ int ptw32_mcs_lock_try_acquire (ptw32_mcs_lock_t * lock, ptw32_mcs_local_node_t * node);
+
void ptw32_mcs_lock_release (ptw32_mcs_local_node_t * node);
+ void ptw32_mcs_node_substitute (ptw32_mcs_local_node_t * new_node, ptw32_mcs_local_node_t * old_node);
+
#ifdef NEED_FTIME
void ptw32_timespec_to_filetime (const struct timespec *ts, FILETIME * ft);
void ptw32_filetime_to_timespec (const FILETIME * ft, struct timespec *ts);
@@ -662,10 +663,8 @@ extern "C"
# endif
# endif
#else
-# ifndef WINCE
# include <process.h>
# endif
-#endif
/*
@@ -673,22 +672,8 @@ extern "C"
* See ptw32_InterlockedCompareExchange.c
*/
#ifndef PTW32_INTERLOCKED_COMPARE_EXCHANGE
-# ifdef _WIN64
- /*
- * InterlockedCompareExchange is an intrinsic function in Win64.
- */
-# define PTW32_INTERLOCKED_COMPARE_EXCHANGE _InterlockedCompareExchange
-# else
- /*
- * The routine pthread_win32_process_attach_np() in pthread_win32_attach_detach_np.c
- * checks at runtime that InterlockedCompareExchange is supported within
- * KERNEL32.DLL (or COREDLL.DLL for WinCE). This allows the same
- * dll to run on all Win32 versions from Win95 onwards. Not sure if this
- * is required for WinCE, but should work just the same anyway.
- */
# define PTW32_INTERLOCKED_COMPARE_EXCHANGE ptw32_interlocked_compare_exchange
# endif
-#endif
#ifndef PTW32_INTERLOCKED_EXCHANGE
#define PTW32_INTERLOCKED_EXCHANGE InterlockedExchange