[Python-Dev] Making the GIL faster & lighter on Windows

Curt Hagenlocher curt at hagenlocher.org
Wed May 27 14:59:48 CEST 2009


On Wed, May 27, 2009 at 4:24 AM, Nick Coghlan <ncoghlan at gmail.com> wrote:
>
> CriticalSections are first come first served on Windows, just like a
> regular mutex.

"Starting with Windows Server 2003 with Service Pack 1 (SP1), threads
waiting on a critical section do not acquire the critical section on a
first-come, first-serve basis."

http://msdn.microsoft.com/en-us/library/ms682530(VS.85).aspx

Windows critical sections use events for kernel-level synchronization.
The user-mode code basically consists of an interlocked instruction
inside the spin loop. When the likelihood of contention is low, a
critical section should be a big win because it won't need to switch
into the kernel. I suspect that contention will be frequent for the
GIL

A good description of pre-Vista Windows critical sections can be found here:
http://msdn.microsoft.com/en-us/magazine/cc164040.aspx

--
Curt Hagenlocher
curt at hagenlocher.org


More information about the Python-Dev mailing list