Author: Armin Rigo <[email protected]>
Branch: fast-gil
Changeset: r72204:c00cc7d1e7c8
Date: 2014-06-24 21:01 +0200
http://bitbucket.org/pypy/pypy/changeset/c00cc7d1e7c8/

Log:    On Windows, a "mutex" does too much by linking to which thread
        locked it. A "semaphore" doesn't.

diff --git a/rpython/translator/c/src/thread_nt.c 
b/rpython/translator/c/src/thread_nt.c
--- a/rpython/translator/c/src/thread_nt.c
+++ b/rpython/translator/c/src/thread_nt.c
@@ -196,7 +196,7 @@
 /* GIL code                                                 */
 /************************************************************/
 
-typedef HANDLE mutex_t;
+typedef HANDLE mutex_t;   /* a semaphore, on Windows */
 
 static void gil_fatal(const char *msg) {
     fprintf(stderr, "Fatal error in the GIL: %s\n", msg);
@@ -204,9 +204,9 @@
 }
 
 static inline void mutex_init(mutex_t *mutex) {
-    *mutex = CreateMutex(NULL, 0, NULL);
+    *mutex = CreateSemaphore(NULL, 1, 1, NULL);
     if (*mutex == NULL)
-        gil_fatal("CreateMutex failed");
+        gil_fatal("CreateSemaphore failed");
 }
 
 static inline void mutex_lock(mutex_t *mutex) {
@@ -214,7 +214,7 @@
 }
 
 static inline void mutex_unlock(mutex_t *mutex) {
-    ReleaseMutex(*mutex);
+    ReleaseSemaphore(*mutex, 1, NULL);
 }
 
 static inline int mutex_lock_timeout(mutex_t *mutex, double delay)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to