summaryrefslogtreecommitdiffstats
path: root/win/tclWinThrd.c
diff options
context:
space:
mode:
authorwelch <welch>1999-08-10 02:42:36 (GMT)
committerwelch <welch>1999-08-10 02:42:36 (GMT)
commit24e9f11aa2c7e32ed6e8a0e6a2c7ae4f0ff12bac (patch)
tree3dda6d8125f2a42360c01e1206096b0d0bd753f3 /win/tclWinThrd.c
parent3a26c6d4498ad6fad866d54c7b23cb221fe21898 (diff)
downloadtcl-24e9f11aa2c7e32ed6e8a0e6a2c7ae4f0ff12bac.zip
tcl-24e9f11aa2c7e32ed6e8a0e6a2c7ae4f0ff12bac.tar.gz
tcl-24e9f11aa2c7e32ed6e8a0e6a2c7ae4f0ff12bac.tar.bz2
Added Tcl_GetAllocMutex for use by tclAlloc.c and tclCkalloc.c
Diffstat (limited to 'win/tclWinThrd.c')
-rw-r--r--win/tclWinThrd.c49
1 files changed, 24 insertions, 25 deletions
diff --git a/win/tclWinThrd.c b/win/tclWinThrd.c
index ade458e..eaf0dc9 100644
--- a/win/tclWinThrd.c
+++ b/win/tclWinThrd.c
@@ -37,6 +37,13 @@ static int init = 0;
static CRITICAL_SECTION initLock;
/*
+ * allocLock is used by Tcl's version of malloc for synchronization.
+ * For obvious reasons, cannot use any dyamically allocated storage.
+ */
+
+static CRITICAL_SECTION allocLock;
+
+/*
* 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
@@ -202,6 +209,7 @@ TclpInitLock()
init = 1;
InitializeCriticalSection(&initLock);
InitializeCriticalSection(&masterLock);
+ InitializeCriticalSection(&allocLock);
}
EnterCriticalSection(&initLock);
}
@@ -264,6 +272,7 @@ TclpMasterLock()
init = 1;
InitializeCriticalSection(&initLock);
InitializeCriticalSection(&masterLock);
+ InitializeCriticalSection(&allocLock);
}
EnterCriticalSection(&masterLock);
}
@@ -292,44 +301,34 @@ TclpMasterUnlock()
LeaveCriticalSection(&masterLock);
}
-#ifdef TCL_THREADS
/*
*----------------------------------------------------------------------
*
- * TclpMutexInit --
- * TclpMutexLock --
- * TclpMutexUnlock --
+ * Tcl_GetAllocMutex
+ *
+ * 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...
*
- * These procedures use an explicitly initialized mutex.
- * These are used by memory allocators for their own mutex.
- *
* Results:
- * None.
+ * A pointer to a mutex that is suitable for passing to
+ * Tcl_MutexLock and Tcl_MutexUnlock.
*
* Side effects:
- * Initialize, Lock, and Unlock the mutex.
+ * None.
*
*----------------------------------------------------------------------
*/
-void
-TclpMutexInit(mPtr)
- TclpMutex *mPtr;
-{
- InitializeCriticalSection((CRITICAL_SECTION *)mPtr);
-}
-void
-TclpMutexLock(mPtr)
- TclpMutex *mPtr;
+Tcl_Mutex *
+Tcl_GetAllocMutex()
{
- EnterCriticalSection((CRITICAL_SECTION *)mPtr);
-}
-void
-TclpMutexUnlock(mPtr)
- TclpMutex *mPtr;
-{
- LeaveCriticalSection((CRITICAL_SECTION *)mPtr);
+#ifdef TCL_THREADS
+ return &allocLock;
+#else
+ return NULL;
+#endif
}