[Python-Dev] Reworking the GIL (original) (raw)

"Martin v. Löwis" martin at v.loewis.de
Mon Nov 2 18:27:40 CET 2009


I did, and it does nothing of what I suggested. I am sure I can make the Windows GIL in cevalgil.h and the mutex in threadnt.h at lot more precise and efficient.

Hmm. I'm skeptical that your code makes it more accurate, and I completely fail to see that it makes it more efficient (by what measurement of efficiency?)

Also, why would making it more accurate make it better? IIUC, accuracy is completely irrelevant here, though efficiency (low overhead) does matter.

This is the kind of code I was talking about, from cevalgil.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.

Hmm. This creates a busy wait loop; if you add larger sleep values, then it loses accuracy.

Why not just call timeBeginPeriod, and then rely on the higher clock rate for WaitForMultipleObjects?

Regards, Martin



More information about the Python-Dev mailing list