Boost logo

Boost :

From: Wilbur Lang (wilburlang_at_[hidden])
Date: 2007-07-18 03:54:25


Hi,

As win32 version of shared mutexes are based "spin and wait", which
leads to poor performance and priority inversions*.
I have an idea about simulate PTHREAD_PROCESS_SHARED with
DuplicateHandle() under win32.

1. anonymous mutex keeps the process id (e.g. hprocess) where
CreateMutex called and HANDLE of mutex (e.g. hmutex).
2. if another process want to shared this mutex, it call
DuplicateHandle() with hSourceProcessHandle=hprocess and
hSourceHandle=hmutex, and return hmutex_dup.
3. the process use hmutex_dup to lock/unlock/try_lock/timed_lock
4. we can optimize performance with cache hmutex_dup.

and a specialized scoped_lock required for anonymous mutex under
windows which didn't use handle directly, but DuplicateHandle.

I'll try this when I'm free (I have to install a windows box first) and
compare it with "spin and wait".

* reference from "Future Improvements" of boost::interprocess, not test
myself.

Best Regards,

Wilbur Lang


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk