[Python-Dev] Bugs in thread_nt.h

Mark Hammond mhammond at skippinet.com.au
Thu Mar 10 03:02:49 CET 2011


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 thread_id ;
> HANDLE hevent ;
> } NRMUTEX, *PNRMUTEX;
>
>
> NRMUTEX
> AllocNonRecursiveMutex(void)
> {
> PNRMUTEX mutex = (PNRMUTEX)_aligned_malloc(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) ;
> _aligned_free(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
>



More information about the Python-Dev mailing list