[Gc] Patch adding another PARALLEL_MARK wait/broadcast
implementation for Win32
ivmai at mail.ru
Mon Sep 14 12:02:35 PDT 2009
This patch (ivmai138.diff) enables PARALLEL_MARK on Win32 without using "pthreads-w32" package and without NT SignalObjectAndWait(). The patch doesn't change the existing implementations. The patch is mostly useful for WinCE.
So, this with patch there are alternative depending on the target (Win32):
1. Cygwin: only pthread-based implementation;
2. pure Win32:
- default: SignalObjectAndWait-based (and AO_fetch_and_add1/sub1() are used);
- DONT_USE_SIGNALANDWAIT: based on multiple event object (one for every marker) and on interlocked XCHG (this is mostly for WinCE) instead of AO_fetch_and_add;
- GC_PTHREADS_PARAMARK: based on pthread primitives (provided by "pthreads-w32" package);
- default is DONT_USE_SIGNALANDWAIT (since there is no SignalObjectAndWait and AO_fetch_and_add1_acquire/sub1_release my be missing);
- GC_PTHREADS_PARAMARK ("pthreads-w32" is ported to Wince, but it's unclear (to me) whether it is actually working (eg., it uses GetCurrentThread() instead of (HANDLE)GetCurrentThreadId())).
Note on performance (for Win32 NT/2000+): impirically DONT_USE_SIGNALANDWAIT should be of same efficiency (at least for 2 CPUs) as SignalObjectAndWait() (for bigger CPUs number, SetEvent() (which is rather heavy-weight) is called more times per one broadcast).
* Makefile.direct (DONT_USE_SIGNALANDWAIT): Add the comment for.
* win32_threads.c (DONT_USE_SIGNALANDWAIT): Always define for
* win32_threads.c (THREAD_HANDLE): Cast Id (of DWORD type) to
HANDLE thru word type (to avoid a compiler warning) for WinCE.
* win32_threads.c (GC_marker_cv, GC_marker_Id): New static array
(only if DONT_USE_SIGNALANDWAIT).
* win32_threads.c (start_mark_threads): Initialize GC_marker_Id
and GC_marker_cv for each helper thread (only if
* win32_threads.c (GC_mark_mutex_state): New static variable (only
* win32_threads.c (GC_mark_mutex_waitcnt,
signalObjectAndWait_func): Don't define if DONT_USE_SIGNALANDWAIT.
* win32_threads.c (GC_acquire_mark_lock, GC_release_mark_lock):
Use InterlockedExchange() over GC_mark_mutex_state (instead of
AO_fetch_and_add()) if DONT_USE_SIGNALANDWAIT.
* win32_threads.c (GC_wait_marker, GC_notify_all_marker):
Implement wait/broadcast primitives using Win32 multiple events
(one for each marker thread) if DONT_USE_SIGNALANDWAIT (instead of
using Win32 SignalObjectAndWait).
* win32_threads.c (GC_thr_init): Don't declare hK32 local
variable, don't check for GC_wnt, and don't initialize
signalObjectAndWait_func if DONT_USE_SIGNALANDWAIT.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 7929 bytes
Desc: not available
Url : https://napali.hpl.hp.com/pipermail/gc/attachments/20090914/35251151/ivmai138.obj
More information about the Gc