From 4a9776cb743c72250cfa8802d28bc097d989cd85 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Thu, 19 Jan 2023 10:21:40 +0900 Subject: [PATCH] Add some concepts related to exit(3) (#17) --- README.md | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/README.md b/README.md index 2f46e7d..db10dc1 100644 --- a/README.md +++ b/README.md @@ -177,6 +177,45 @@ TID is a 32-bit integer to identify threads created with `wasi_thread_spawn`. For example, it can be used to indicate the main thread, which doesn't have a TID in the current version of this proposal. +### Process + +* A process is a group of threads. + +* The main thread starts with a process which only contains + the main thread. + +* Threads created by a thread in a process using `wasi_thread_spawn` + are added to the process. + +* When a thread is terminated, it's removed from the process. + +### Voluntary thread termination + +A thread can terminate itself voluntarily by returning from +`wasi_thread_start`. + +### Changes to WASI `proc_exit` + +With this proposal, the `proc_exit` function takes extra responsibility +to terminate all threads in the process, not only the calling one. + +Any of the threads in the process can call `proc_exit`. + +### Traps + +When a trap occurs in any thread, the entire process is terminated. + +### Process exit status + +If one or more threads call WASI `proc_exit` or raise a trap, +one of them is chosen by the runtime to represent the exit status +of the process. +It's non deterministic which one is chosen. + +If all the threads in the process have been terminated without calling +`proc_exit` or raising a trap, it's treated as if the last thread called +`proc_exit` with exit code 0. + #### Design choice: pthreads One of the goals of this API is to be able to support `pthreads` for C compiled