示例#1
0
static void
func(void * p) {
	struct args * arg = p;
	if (arg->wait) {
		thread_event_wait(arg->wait);
	}
	printf("n = %d\n", arg->n);
	if (arg->trigger) {
		thread_event_trigger(arg->trigger);
	}
}
示例#2
0
static void
worker_func(void *p) {
	struct worker *w = p;
	for (;;) {
		w->suspend = 0;
		while (run_slice(w)) {
			struct workshop * ws = w->workshop;
			int i;
			for (i=0;i<ws->threads;i++) {
				struct worker *w = &ws->w[i];
				if (w->suspend) {
					thread_event_trigger(&w->event);
				}
			}
		}
		w->suspend = 1;
		thread_event_wait(&w->event);
	}
}