[issue11618] Locks broken wrt timeouts on Windows

Kristján Valur Jónsson report at bugs.python.org
Mon Apr 30 12:03:10 CEST 2012


Kristján Valur Jónsson <kristjan at ccpgames.com> added the comment:

Martin, I think you misunderstand completely. the patch is _not_ about using the VISTA features.  It is about not using a "mutex" for threading.lock.

Currently, the locks in python use Mutex objects, and a WaitForSingleObjects() system call to acquire them.
This patch replaces theses locks with user-level objects (critical sections and condition variables.).  This drops the time needed for an uncontended acquire/release by 60% since there is no kernel transition and scheduling.

The patch comes in two flavors.  The current version _emulates_ condition variables on Windows by the same mechanism as I introduced for the new GIL, that is, using a combination of "critical section" objects and a construct made of a "semaphore" and a counter.

Also provided, for those that want, and for future reference, is a version that uses native system objects (windows condition variables and SRWLocks).  I can drop them from the patch to make you happy, but they are dormant and nicely show how conditional compilation can switch in more modern features for a different target architecture.

K

> -----Original Message-----
> From: Martin v. Löwis [mailto:report at bugs.python.org]
> Sent: 30. apríl 2012 09:05
> To: Kristján Valur Jónsson
> Subject: [issue11618] Locks broken wrt timeouts on Windows
> 
> 
> Martin v. Löwis <martin at v.loewis.de> added the comment:
> 
> As it stands, the patch is pointless, and can safely be rejected. We will just
> not have defined NTDDI_VERSION at NTDDI_VISTA for any foreseeable
> future, so all the Vista-specific code can be eliminated from the patch.
> 
> Python had been using dynamic checking for API "forever". In 2.5, there was
> a check for presence of GetFileAttributesExA; in 2.4, there was a check for
> CryptAcquireContextA.
> 
> ----------
> 
> _______________________________________
> Python tracker <report at bugs.python.org>
> <http://bugs.python.org/issue11618>
> _______________________________________

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue11618>
_______________________________________


More information about the Python-bugs-list mailing list