diff options
author | Alex Auvolat <alex.auvolat@ens.fr> | 2015-03-04 11:51:30 +0100 |
---|---|---|
committer | Alex Auvolat <alex.auvolat@ens.fr> | 2015-03-04 11:51:30 +0100 |
commit | 503f176e001ddf15e6e32bc912cf10b5764bc23b (patch) | |
tree | 2595bc45e582df3ede9241c00656b65866301e38 /src/kernel/core/worker.c | |
parent | 0934f9943ef7bdec8c2eee3ea31b5e0f1e8a3faf (diff) | |
download | kogata-503f176e001ddf15e6e32bc912cf10b5764bc23b.tar.gz kogata-503f176e001ddf15e6e32bc912cf10b5764bc23b.zip |
Process exiting & thread termination. IMPORTANT NOTE FOLLOWS.
Threads may now communicate via wait_on(void* ressource) and resume_on (void* ressource).
Previous pause() is replaced by wait_on(current_thread) and resume(thread) by resume_on(thread).
wait_on(x) may return false, indicating that the reason for returning is NOT that resume_on(x)
was called but something else happenned. Typically false indicates that the curent thread
is being killed and must terminate its kernel-land processing as soon as possible.
Diffstat (limited to 'src/kernel/core/worker.c')
-rw-r--r-- | src/kernel/core/worker.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/kernel/core/worker.c b/src/kernel/core/worker.c index e50085a..c3fa04d 100644 --- a/src/kernel/core/worker.c +++ b/src/kernel/core/worker.c @@ -36,7 +36,10 @@ void start_workers(int n) { nworkers = n; for (int i = 0; i < n; i++) { workers[i] = new_thread(worker_thread, 0); - dbg_printf("New worker thread: 0x%p\n", workers[i]); + if (workers[i] != 0) { + dbg_printf("New worker thread: 0x%p\n", workers[i]); + start_thread(workers[i]); + } } } @@ -59,7 +62,7 @@ void worker_thread(void* x) { t->fun(t->data); free(t); } else { - pause(); + ASSERT(wait_on(current_thread)); } } } @@ -89,7 +92,7 @@ void worker_notify_time(int usecs) { time += usecs; if (next_task_time <= time) { for (int i = 0; i < nworkers; i++) { - if (resume_thread(workers[i])) break; + if (resume_on(workers[i])) break; } } } |