アットウィキロゴ

tcl > win > tclWinThrd.c

概要



include

"tclWinInt.h"
<sys/stat.h>


変数宣言


/*
* This is the master lock used to serialize access to other serialization
* data structures.
*/

static CRITICAL_SECTION masterLock;
static int init = 0;
#define
MASTER_LOCK TclpMasterLock()
#define
MASTER_UNLOCK TclpMasterUnlock()


/*
* This is the master lock used to serialize initialization and finalization
* of Tcl as a whole.
*/

static CRITICAL_SECTION initLock;

/*
* allocLock is used by Tcl's version of malloc for synchronization. For
* obvious reasons, cannot use any dyamically allocated storage.
*/

#ifdef
TCL_THREADS

static struct Tcl_Mutex_ {
   CRITICAL_SECTION crit;
} allocLock;
static Tcl_Mutex allocLockPtr = &allocLock;
static int allocOnce = 0;

#endif
/* TCL_THREADS */

/*
* The joinLock serializes Create- and ExitThread. This is necessary to
* prevent a race where a new joinable thread exits before the creating thread
* had the time to create the necessary data structures in the emulation
* layer.
*/

static CRITICAL_SECTION joinLock;

/*
* Condition variables are implemented with a combination of a per-thread
* Windows Event and a per-condition waiting queue. The idea is that each
* thread has its own Event that it waits on when it is doing a ConditionWait;
* it uses the same event for all condition variables because it only waits on
* one at a time. Each condition variable has a queue of waiting threads, and
* a mutex used to serialize access to this queue.
*
* Special thanks to David Nichols and Jim Davidson for advice on the
* Condition Variable implementation.
*/

/*
* The per-thread event and queue pointers.
*/

#ifdef
TCL_THREADS

typedef struct ThreadSpecificData {
   HANDLE condEvent;			/* Per-thread condition event */
   struct ThreadSpecificData *nextPtr;	/* Queue pointers */
   struct ThreadSpecificData *prevPtr;
   int flags;				/* See flags below */
} ThreadSpecificData;
static Tcl_ThreadDataKey dataKey;

#endif
/* TCL_THREADS */

/*
* State bits for the thread.
* WIN_THREAD_UNINIT		Uninitialized. Must be zero because of the way
*				ThreadSpecificData is created.
* WIN_THREAD_RUNNING		Running, not waiting.
* WIN_THREAD_BLOCKED		Waiting, or trying to wait.
*/

#define
WIN_THREAD_UNINIT 0x0
#define
WIN_THREAD_RUNNING 0x1
#define
WIN_THREAD_BLOCKED 0x2

/*
* The per condition queue pointers and the Mutex used to serialize access to
* the queue.
*/

typedef struct WinCondition {
   CRITICAL_SECTION condLock;	/* Lock to serialize queuing on the
			 * condition. */
   struct ThreadSpecificData *firstPtr;	/* Queue pointers */
   struct ThreadSpecificData *lastPtr;
} WinCondition;

/*
* Additions by AOL for specialized thread memory allocator.
*/

#ifdef
USE_THREAD_ALLOC
static int once;
static DWORD tlsKey;

typedef struct allocMutex {
   Tcl_Mutex	     tlock;
   CRITICAL_SECTION wlock;
} allocMutex;
#endif
/* USE_THREAD_ALLOC */


関数

最終更新:2011年11月10日 22:16