static void add_child_status(int pid, int status) { Child_Status *st; /* Search for existing record, which will have a signal_fd: */ mzrt_mutex_lock(child_status_lock); for (st = child_statuses; st; st = st->next) { if (st->pid == pid) break; } if (!st) { /* must have terminated before it was registered (and since we detected it, it must not be a group) */ st = malloc(sizeof(Child_Status)); st->pid = pid; st->signal_fd = NULL; st->next = child_statuses; child_statuses = st; st->next_unused = NULL; st->unneeded = 0; st->is_group = 0; } st->status = status; st->done = 1; if (st->signal_fd && st->is_group) remove_group_signal_fd(st->signal_fd); mzrt_mutex_unlock(child_status_lock); if (st->signal_fd) scheme_signal_received_at(st->signal_fd); if (st->unneeded) (void)scheme_get_child_status(st->pid, 0, NULL); }
static BOOL WINAPI ConsoleHandler(DWORD op) { if (stdio_kills_prog) { ReleaseSemaphore(waiting_sema, 1, NULL); } else { scheme_break_main_thread_at(orig_break_handle); scheme_signal_received_at(orig_signal_handle); } return TRUE; }
static void *mz_proc_thread_wait_worker(void *data) { void *rc; proc_thread_wait_data *wd = (proc_thread_wait_data*) data; rc = mz_proc_thread_wait(wd->proc_thread); wd->rc = (intptr_t) rc; wd->ready = 1; scheme_signal_received_at(wd->wake_fd); return NULL; }
static void do_group_signal_fds() { int i; for (i = 0; i < signal_fd_count; i++) { if (signal_fds[i].refcount) { scheme_signal_received_at(signal_fds[i].signal_fd); } } }
static void scheme_place_async_send(Scheme_Place_Async_Channel *ch, Scheme_Object *uo) { void *msg_memory = NULL; Scheme_Object *o; int cnt; o = scheme_places_serialize(uo, &msg_memory); mzrt_mutex_lock(ch->lock); { cnt = ch->count; if (ch->count == ch->size) { /* GROW QUEUE */ Scheme_Object **new_msgs; void **new_msg_memory; new_msgs = GC_master_malloc(sizeof(Scheme_Object*) * ch->size * 2); new_msg_memory = GC_master_malloc(sizeof(void*) * ch->size * 2); if (ch->out < ch->in) { memcpy(new_msgs, ch->msgs + ch->out, sizeof(Scheme_Object *) * (ch->in - ch->out)); memcpy(new_msg_memory, ch->msg_memory + ch->out, sizeof(void*) * (ch->in - ch->out)); } else { int s1 = (ch->size - ch->out); memcpy(new_msgs, ch->msgs + ch->out, sizeof(Scheme_Object *) * s1); memcpy(new_msgs + s1, ch->msgs, sizeof(Scheme_Object *) * ch->in); memcpy(new_msg_memory, ch->msg_memory + ch->out, sizeof(void*) * s1); memcpy(new_msg_memory + s1, ch->msg_memory, sizeof(void*) * ch->in); } ch->msgs = new_msgs; ch->msg_memory = new_msg_memory; ch->in = ch->size; ch->out = 0; ch->size *= 2; } ch->msgs[ch->in] = o; ch->msg_memory[ch->in] = msg_memory; ++ch->count; ch->in = (++ch->in % ch->size); } mzrt_mutex_unlock(ch->lock); if (!cnt && ch->wakeup_signal) { /*wake up possibly sleeping receiver */ scheme_signal_received_at(ch->wakeup_signal); } }
static void user_break_hit(int ignore) { scheme_break_main_thread_at(break_handle); scheme_signal_received_at(signal_handle); # ifdef SIGSET_NEEDS_REINSTALL MZ_SIGSET(SIGINT, user_break_hit); # endif # ifdef MZ_PRECISE_GC # ifndef GC_STACK_CALLEE_RESTORE /* Restore variable stack. */ GC_variable_stack = (void **)__gc_var_stack__[0]; # endif # endif }
static BOOL WINAPI ConsoleBreakHandler(DWORD op) { scheme_break_main_thread_at(break_handle); scheme_signal_received_at(signal_handle); return TRUE; }