[Python-Dev] Bugs in thread_nt.h (original) (raw)
Mark Hammond mhammond at skippinet.com.au
Thu Mar 10 03:02:49 CET 2011
- Previous message: [Python-Dev] Bugs in thread_nt.h
- Next message: [Python-Dev] Bugs in thread_nt.h
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
These issues are best put in the tracker so they don't get lost - especially at the moment with lots of regulars at pycon.
It would also be good to know if there is an actual behaviour bug caused by this (ie, what problems can be observed which are caused by the current code?)
Cheers,
Mark
On 10/03/2011 12:25 PM, Sturla Molden wrote:
Atomic operations (InterlockedCompareExchange, et al.) are used on the field 'owned' in NRMUTEX. These methods require the memory to be aligned on 32-byte boundaries. They also require the volatile qualifer. Three small changes are therefore needed (see below).
Regards, Sturla Molden
typedef struct NRMUTEX { volatile LONG owned ; /* Bugfix: remember volatile */ DWORD threadid ; HANDLE hevent ; } NRMUTEX, *PNRMUTEX; NRMUTEX AllocNonRecursiveMutex(void) { PNRMUTEX mutex = (PNRMUTEX)alignedmalloc(sizeof(NRMUTEX),32) ; /* Bugfix: align to 32-bytes */ if (mutex && !InitializeNonRecursiveMutex(mutex)) { free(mutex) ; mutex = NULL ; } return mutex ; } void FreeNonRecursiveMutex(PNRMUTEX mutex) { if (mutex) { DeleteNonRecursiveMutex(mutex) ; alignedfree(mutex) ; /* Bugfix: align to 32-bytes */ } }
Python-Dev mailing list Python-Dev at python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/skippy.hammond%40gmail.com
- Previous message: [Python-Dev] Bugs in thread_nt.h
- Next message: [Python-Dev] Bugs in thread_nt.h
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]