[Python-checkins] r76006 - sandbox/trunk/newgil/Python/ceval_gil.h
antoine.pitrou
python-checkins at python.org
Sun Nov 1 12:30:03 CET 2009
Author: antoine.pitrou
Date: Sun Nov 1 12:30:03 2009
New Revision: 76006
Log:
Add a #define for priority requests, and disable them by default
Modified:
sandbox/trunk/newgil/Python/ceval_gil.h
Modified: sandbox/trunk/newgil/Python/ceval_gil.h
==============================================================================
--- sandbox/trunk/newgil/Python/ceval_gil.h (original)
+++ sandbox/trunk/newgil/Python/ceval_gil.h Sun Nov 1 12:30:03 2009
@@ -17,6 +17,10 @@
#undef FORCE_SWITCHING
#define FORCE_SWITCHING
+/* Enable priority requests */
+#undef PRIO_REQUESTS
+/* #define PRIO_REQUESTS */
+
#undef TRACE_PRIO
/* #define TRACE_PRIO */
@@ -171,12 +175,6 @@
In addition, the mutex also protects the above variables. */
static COND_T gil_cond;
static MUTEX_T gil_mutex;
-/* This mutex is taken when a priority request is made, and released when
- it is finally honoured.
- Other threads can sleep by trying to lock the mutex. */
-static MUTEX_T prio_mutex;
-/* The thread making the prio request, or NULL. */
-static volatile PyThreadState *prio_request = NULL;
#ifdef FORCE_SWITCHING
/* This condition variable forces the GIL-releasing thread to wait for
@@ -185,6 +183,12 @@
static MUTEX_T switch_mutex;
#endif
+/* This mutex is taken when a priority request is made, and released when
+ it is finally honoured.
+ Other threads can sleep by trying to lock the mutex. */
+static MUTEX_T prio_mutex;
+/* The thread making the prio request, or NULL. */
+static volatile PyThreadState *prio_request = NULL;
#define YIELD_IF_PRIO_REQUEST() \
do { \
@@ -195,7 +199,6 @@
} while (0)
-
static int gil_created(void)
{
return gil_locked >= 0;
@@ -204,7 +207,9 @@
static void create_gil(void)
{
MUTEX_INIT(gil_mutex);
+#ifdef PRIO_REQUESTS
MUTEX_INIT(prio_mutex);
+#endif
#ifdef FORCE_SWITCHING
MUTEX_INIT(switch_mutex);
#endif
@@ -258,7 +263,9 @@
/* If another thread is requesting priority, give it a chance to run
before we take the mutex.
*/
+#ifdef PRIO_REQUESTS
YIELD_IF_PRIO_REQUEST();
+#endif
err = errno;
MUTEX_LOCK(gil_mutex);
@@ -356,7 +363,11 @@
static void take_gil_prio(PyThreadState *tstate)
{
+#ifdef PRIO_REQUESTS
_take_gil(tstate, 1);
+#else
+ _take_gil(tstate, 0);
+#endif
}
void _PyEval_SetSwitchInterval(double seconds)
More information about the Python-checkins
mailing list