diff options
author | redman <redman> | 1999-08-10 17:35:14 (GMT) |
---|---|---|
committer | redman <redman> | 1999-08-10 17:35:14 (GMT) |
commit | 324d20b570be85ce259bea58a1d37768b7a01634 (patch) | |
tree | 17312f8cada055139e9649674bdf4d701fdf2f13 /win/tclWinThrd.c | |
parent | 7cd43815d0b5a7b4c81e4fd496673bc241e83eb1 (diff) | |
download | tcl-324d20b570be85ce259bea58a1d37768b7a01634.zip tcl-324d20b570be85ce259bea58a1d37768b7a01634.tar.gz tcl-324d20b570be85ce259bea58a1d37768b7a01634.tar.bz2 |
* generic/tclListObj.c:core_8_2_b3_base
* generic/tcl.decls:
* generic/tclDecls.h: Applied patch from Jim Ingham to change the
prototype of Tcl_ListObjGetElements to have the last argument have
a CONST so that you can feed it the objv that you get from the
standard TclObj command proc.
* generic/tclAlloc.c:
* generic/tclCmdIL.c:
* generic/tclIO.c:
* generic/tclThread.c:
* win/tclWinThrd.c:
* unix/tclUnixThrd.c: Fixed Brent's changes so that they work on
Windows (and he fixed the bug in the Unix thread implementation).
Diffstat (limited to 'win/tclWinThrd.c')
-rw-r--r-- | win/tclWinThrd.c | 71 |
1 files changed, 36 insertions, 35 deletions
diff --git a/win/tclWinThrd.c b/win/tclWinThrd.c index eaf0dc9..e12be89 100644 --- a/win/tclWinThrd.c +++ b/win/tclWinThrd.c @@ -42,6 +42,7 @@ static CRITICAL_SECTION initLock; */ static CRITICAL_SECTION allocLock; +static Tcl_Mutex allocLockPtr = (Tcl_Mutex) &allocLock;
/* * Condition variables are implemented with a combination of a @@ -199,18 +200,17 @@ Tcl_GetCurrentThread() void TclpInitLock() { - if (!init) { - /* - * There is a fundamental race here that is solved by creating - * the first Tcl interpreter in a single threaded environment. - * Once the interpreter has been created, it is safe to create - * more threads that create interpreters in parallel. - */ - init = 1; - InitializeCriticalSection(&initLock); - InitializeCriticalSection(&masterLock); - InitializeCriticalSection(&allocLock); - } + if (!init) {
+ /*
+ * There is a fundamental race here that is solved by creating
+ * the first Tcl interpreter in a single threaded environment.
+ * Once the interpreter has been created, it is safe to create
+ * more threads that create interpreters in parallel.
+ */
+ init = 1;
+ InitializeCriticalSection(&initLock);
+ InitializeCriticalSection(&masterLock);
+ }
EnterCriticalSection(&initLock); } @@ -272,7 +272,6 @@ TclpMasterLock() init = 1; InitializeCriticalSection(&initLock); InitializeCriticalSection(&masterLock); - InitializeCriticalSection(&allocLock); } EnterCriticalSection(&masterLock); } @@ -281,54 +280,56 @@ TclpMasterLock() /* *---------------------------------------------------------------------- * - * TclpMasterUnlock + * Tcl_GetAllocMutex * - * This procedure is used to release a lock that serializes creation - * and deletion of synchronization objects. + * This procedure returns a pointer to a statically initialized + * mutex for use by the memory allocator. The alloctor must + * use this lock, because all other locks are allocated... * * Results: - * None. + * A pointer to a mutex that is suitable for passing to + * Tcl_MutexLock and Tcl_MutexUnlock. * * Side effects: - * Release the master mutex. + * None. * *---------------------------------------------------------------------- */ -void -TclpMasterUnlock() +Tcl_Mutex * +Tcl_GetAllocMutex() { - LeaveCriticalSection(&masterLock); +#ifdef TCL_THREADS
+ InitializeCriticalSection(&allocLock);
+ return &allocLockPtr; +#else + return NULL; +#endif } +#ifdef TCL_THREADS /* *---------------------------------------------------------------------- * - * Tcl_GetAllocMutex + * TclpMasterUnlock * - * This procedure returns a pointer to a statically initialized - * mutex for use by the memory allocator. The alloctor must - * use this lock, because all other locks are allocated... + * This procedure is used to release a lock that serializes creation + * and deletion of synchronization objects. * * Results: - * A pointer to a mutex that is suitable for passing to - * Tcl_MutexLock and Tcl_MutexUnlock. + * None. * * Side effects: - * None. + * Release the master mutex. * *---------------------------------------------------------------------- */ -Tcl_Mutex * -Tcl_GetAllocMutex() +void +TclpMasterUnlock() { -#ifdef TCL_THREADS - return &allocLock; -#else - return NULL; -#endif + LeaveCriticalSection(&masterLock); } |