[Python-Dev] Reworking the GIL

Sturla Molden sturla at molden.no
Mon Nov 2 15:07:14 CET 2009


Martin v. Löwis skrev:
> Maybe you should study the code under discussion before making such
> a proposal.
>
I did, and it does nothing of what I suggested. I am sure I can make the 
Windows GIL
in ceval_gil.h and the mutex in thread_nt.h at lot more precise and 
efficient.

This is the kind of code I was talking about, from ceval_gil.h:

r = WaitForMultipleObjects(2, objects, TRUE, milliseconds);

I would turn on multimedia timer (it is not on by default), and replace 
this
call with a loop, approximately like this:

for (;;) {
   r = WaitForMultipleObjects(2, objects, TRUE, 0);
   /* blah blah blah */   
   QueryPerformanceCounter(&cnt);  
   if (cnt > timeout) break;
   Sleep(0);
}

And the timeout "milliseconds" would now be computed from querying the 
performance
counter, instead of unreliably by the Windows NT kernel.



Sturla












More information about the Python-Dev mailing list