+ if (opts.options.fork) {
+ cstdio.fflush(null); // avoid duplicated FILE* output
+ os.pid_t child_pid = os.fork();
+ assert (child_pid != -1); // don't accept errors in non-release mode
+ switch (child_pid) {
+ case -1: // if fork() fails, fallback to stop-the-world
+ opts.options.fork = false;
+ break;
+ case 0: // child process (i.e. the collectors mark phase)
+ mark(stackTop);
+ cstdlib.exit(0);
+ break; // bogus, will never reach here
+ default: // parent process (i.e. the mutator)
+ // start the world again and wait for the mark phase to finish
+ thread_resumeAll();
+ gc.stats.world_started();
+ int status = void;
+ os.pid_t wait_pid = os.waitpid(child_pid, &status, 0);
+ assert (wait_pid == child_pid);
+ return sweep();
+ }
+
+ }
+
+ // if we reach here, we are using the standard stop-the-world collection
+ mark(stackTop);
+ thread_resumeAll();
+ gc.stats.world_started();
+
+ return sweep();
+}
+
+
+/**
+ *
+ */
+void mark(void *stackTop)
+{
+ debug(COLLECT_PRINTF) printf("\tmark()\n");