Python threading (was: Re: global interpreter lock not working as it should)

Armin Steinhoff a-steinhoff at web.de
Tue Aug 6 02:57:58 EDT 2002


a-steinhoff at web.de (Armin Steinhoff) wrote in message news:<ddc19db7.0208050743.590e56bc at posting.google.com>...
[clip ..]
> 

All previous tests were done on a 700MHz QNX 6 machine using SCHED_RR.
QNX 6 is POSIX --> so thread_pthread.h is the issue.

-------------------------------------------------------------------------------
> My conclusion: insert a sched_yield if the ceval.c code is called from
> a thread.
> 
> #ifdef WITH_THREAD
> 			if (interpreter_lock) {
> 				/* Give another thread a chance */
> 
> 				if (PyThreadState_Swap(NULL) != tstate)
> 					Py_FatalError("ceval: tstate mix-up");
> 				PyThread_release_lock(interpreter_lock);
> 
> 				/* Other threads may run now */ 
> -->          if (called_from_a_thread)
> -->              sched_yield()   

No ... this not the solution.
I will try to implement the following logic:

-->          if (at_least_1_thread_is_waiting_for_the_interpreter-lock)
-->              sched_yield()   

This should do what we need ...

Where can a find a formal definition of the sematic of the
acquire/relaese lock procedures ?


Armin
           
> 
> 				PyThread_acquire_lock(interpreter_lock, 1);
> 				if (PyThreadState_Swap(tstate) != NULL)
> 					Py_FatalError("ceval: orphan tstate");
> 			}
> #endif
> 
> Armin



More information about the Python-list mailing list