GC_INNER GC_bool GC_is_mach_marker(thread_act_t thread)
{
int i;
- for (i = 0; i < GC_markers - 1; i++) {
+ for (i = 0; i < GC_markers_m1; i++) {
if (marker_mach_threads[i] == thread)
return TRUE;
}
}
}
# endif /* HPUX || GC_DGUX386_THREADS */
- for (i = 0; i < GC_markers - 1; ++i) {
+ for (i = 0; i < GC_markers_m1; ++i) {
if (0 != REAL_FUNC(pthread_create)(GC_mark_threads + i, &attr,
GC_mark_thread, (void *)(word)i)) {
WARN("Marker thread creation failed, errno = %" WARN_PRIdPTR "\n",
errno);
/* Don't try to create other marker threads. */
- GC_markers = i + 1;
+ GC_markers_m1 = i;
if (i == 0) GC_parallel = FALSE;
break;
}
}
if (GC_print_stats) {
- GC_log_printf("Started %d mark helper threads\n", GC_markers - 1);
+ GC_log_printf("Started %d mark helper threads\n", GC_markers_m1);
}
pthread_attr_destroy(&attr);
}
GC_ASSERT(I_HOLD_LOCK());
# ifdef PARALLEL_MARK
- for (i = 0; i < GC_markers - 1; ++i) {
+ for (i = 0; i < GC_markers_m1; ++i) {
if (marker_sp[i] > lo && marker_sp[i] < hi) return TRUE;
# ifdef IA64
if (marker_bsp[i] > lo && marker_bsp[i] < hi) return TRUE;
GC_ASSERT(I_HOLD_LOCK());
# ifdef PARALLEL_MARK
- for (i = 0; i < GC_markers - 1; ++i) {
+ for (i = 0; i < GC_markers_m1; ++i) {
if (marker_sp[i] > result && marker_sp[i] < bound)
result = marker_sp[i];
}
# ifdef PARALLEL_MARK
/* Turn off parallel marking in the child, since we are probably */
/* just going to exec, and we would have to restart mark threads. */
- GC_markers = 1;
+ GC_markers_m1 = 0;
GC_parallel = FALSE;
# endif /* PARALLEL_MARK */
RESTORE_CANCEL(fork_cancel_state);
WARN("GC_get_nprocs() returned %" WARN_PRIdPTR "\n", GC_nprocs);
GC_nprocs = 2; /* assume dual-core */
# ifdef PARALLEL_MARK
- GC_markers = 1;
+ GC_markers_m1 = 0; /* but use only one marker */
# endif
} else {
# ifdef PARALLEL_MARK
{
char * markers_string = GETENV("GC_MARKERS");
if (markers_string != NULL) {
- GC_markers = atoi(markers_string);
- if (GC_markers > MAX_MARKERS) {
+ GC_markers_m1 = atoi(markers_string) - 1;
+ if (GC_markers_m1 >= MAX_MARKERS) {
WARN("Limiting number of mark threads\n", 0);
- GC_markers = MAX_MARKERS;
+ GC_markers_m1 = MAX_MARKERS - 1;
}
} else {
- GC_markers = GC_nprocs;
+ GC_markers_m1 = GC_nprocs - 1;
# ifdef GC_MIN_MARKERS
/* This is primarily for targets without getenv(). */
- if (GC_markers < GC_MIN_MARKERS)
- GC_markers = GC_MIN_MARKERS;
+ if (GC_markers_m1 < GC_MIN_MARKERS - 1)
+ GC_markers_m1 = GC_MIN_MARKERS - 1;
# endif
- if (GC_markers >= MAX_MARKERS)
- GC_markers = MAX_MARKERS; /* silently limit GC_markers value */
+ if (GC_markers_m1 >= MAX_MARKERS)
+ GC_markers_m1 = MAX_MARKERS - 1; /* silently limit the value */
}
}
# endif
if (GC_print_stats) {
GC_log_printf(
"Number of processors = %d, number of marker threads = %d\n",
- GC_nprocs, GC_markers);
+ GC_nprocs, GC_markers_m1 + 1);
}
- if (GC_markers <= 1) {
+ if (GC_markers_m1 <= 0) {
GC_parallel = FALSE;
if (GC_print_stats) {
GC_log_printf("Single marker thread, turning off parallel marking\n");
}
}
# ifdef PARALLEL_MARK
- for (i = 0; i < GC_markers - 1; ++i) {
+ for (i = 0; i < GC_markers_m1; ++i) {
ptr_t s = marker_sp[i];
# ifdef IA64
/* FIXME: not implemented */
# endif
/* start_mark_threads() is the same as in pthread_support.c except for: */
- /* - GC_markers value is adjusted already; */
+ /* - GC_markers_m1 value is adjusted already; */
/* - thread stack is assumed to be large enough; and */
/* - statistics about the number of marker threads is printed outside. */
static void start_mark_threads(void)
if (0 != pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED))
ABORT("pthread_attr_setdetachstate failed");
- for (i = 0; i < GC_markers - 1; ++i) {
+ for (i = 0; i < GC_markers_m1; ++i) {
marker_last_stack_min[i] = ADDR_LIMIT;
if (0 != pthread_create(&new_thread, &attr,
GC_mark_thread, (void *)(word)i)) {
WARN("Marker thread creation failed.\n", 0);
/* Don't try to create other marker threads. */
- GC_markers = i + 1;
+ GC_markers_m1 = i;
if (i == 0) GC_parallel = FALSE;
break;
}
# ifdef DONT_USE_SIGNALANDWAIT
/* Initialize GC_marker_cv[] and GC_marker_Id[] fully before */
/* starting the first helper thread. */
- for (i = 0; i < GC_markers - 1; ++i) {
+ for (i = 0; i < GC_markers_m1; ++i) {
GC_marker_Id[i] = GetCurrentThreadId();
if ((GC_marker_cv[i] = CreateEvent(NULL /* attrs */,
TRUE /* isManualReset */,
}
# endif
- for (i = 0; i < GC_markers - 1; ++i) {
+ for (i = 0; i < GC_markers_m1; ++i) {
marker_last_stack_min[i] = ADDR_LIMIT;
# ifdef MSWINCE
/* There is no _beginthreadex() in WinCE. */
# endif
}
- /* Adjust GC_markers (and free unused resources) in case of failure. */
+ /* Adjust GC_markers_m1 (and free unused resources) if failed. */
# ifdef DONT_USE_SIGNALANDWAIT
- while (GC_markers > i + 1) {
- GC_markers--;
- CloseHandle(GC_marker_cv[GC_markers - 1]);
+ while (GC_markers_m1 > i) {
+ GC_markers_m1--;
+ CloseHandle(GC_marker_cv[GC_markers_m1]);
}
# else
- GC_markers = i + 1;
+ GC_markers_m1 = i;
# endif
if (i == 0) {
GC_parallel = FALSE;
{
HANDLE event = mark_cv;
DWORD thread_id = GetCurrentThreadId();
- int i = GC_markers - 1;
+ int i = GC_markers_m1;
+
while (i-- > 0) {
if (GC_marker_Id[i] == thread_id) {
event = GC_marker_cv[i];
GC_INNER void GC_notify_all_marker(void)
{
DWORD thread_id = GetCurrentThreadId();
- int i = GC_markers - 1;
+ int i = GC_markers_m1;
+
while (i-- > 0) {
/* Notify every marker ignoring self (for efficiency). */
if (SetEvent(GC_marker_Id[i] != thread_id ? GC_marker_cv[i] :
GC_ASSERT(sb_result == GC_SUCCESS);
# if defined(PARALLEL_MARK)
- /* Set GC_markers. */
+ /* Set GC_markers_m1. */
{
char * markers_string = GETENV("GC_MARKERS");
if (markers_string != NULL) {
- GC_markers = atoi(markers_string);
- if (GC_markers > MAX_MARKERS) {
+ GC_markers_m1 = atoi(markers_string) - 1;
+ if (GC_markers_m1 >= MAX_MARKERS) {
WARN("Limiting number of mark threads\n", 0);
- GC_markers = MAX_MARKERS;
+ GC_markers_m1 = MAX_MARKERS - 1;
}
} else {
# ifdef MSWINCE
/* There is no GetProcessAffinityMask() in WinCE. */
/* GC_sysinfo is already initialized. */
- GC_markers = (int)GC_sysinfo.dwNumberOfProcessors;
+ GC_markers_m1 = (int)GC_sysinfo.dwNumberOfProcessors - 1;
# else
# ifdef _WIN64
DWORD_PTR procMask = 0;
ncpu++;
} while ((procMask &= procMask - 1) != 0);
}
- GC_markers = ncpu;
+ GC_markers_m1 = ncpu - 1;
# endif
# ifdef GC_MIN_MARKERS
/* This is primarily for testing on systems without getenv(). */
- if (GC_markers < GC_MIN_MARKERS)
- GC_markers = GC_MIN_MARKERS;
+ if (GC_markers_m1 < GC_MIN_MARKERS - 1)
+ GC_markers_m1 = GC_MIN_MARKERS - 1;
# endif
- if (GC_markers >= MAX_MARKERS)
- GC_markers = MAX_MARKERS; /* silently limit GC_markers value */
+ if (GC_markers_m1 >= MAX_MARKERS)
+ GC_markers_m1 = MAX_MARKERS - 1; /* silently limit the value */
}
}
HMODULE hK32;
/* SignalObjectAndWait() API call works only under NT. */
# endif
- if (GC_win32_dll_threads || GC_markers <= 1
+ if (GC_win32_dll_threads || GC_markers_m1 <= 0
# if !defined(GC_PTHREADS_PARAMARK) && !defined(MSWINCE) \
&& !defined(DONT_USE_SIGNALANDWAIT)
|| GC_wnt == FALSE
) {
/* Disable parallel marking. */
GC_parallel = FALSE;
- GC_markers = 1;
+ GC_markers_m1 = 0;
} else {
# ifndef GC_PTHREADS_PARAMARK
/* Initialize Win32 event objects for parallel marking. */
/* If we are using a parallel marker, actually start helper threads. */
if (GC_parallel) start_mark_threads();
if (GC_print_stats) {
- GC_log_printf("Started %d mark helper threads\n", GC_markers - 1);
+ GC_log_printf("Started %d mark helper threads\n", GC_markers_m1);
}
# endif
}