-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add some concepts related to exit(3) #17
Changes from 1 commit
2b7fb32
ccc5811
ec8172d
dc1ac30
f74d69d
c732034
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
* Introduce wasi_thread_exit * Introduce thread group and its exit status
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,10 +84,11 @@ threads. | |
|
||
### API walk-through | ||
|
||
The API consists of a single function. In pseudo-code: | ||
The API consists of two functions. In pseudo-code: | ||
|
||
```C | ||
status wasi_thread_spawn(thread_start_arg* start_arg); | ||
void wasi_thread_exit(void); | ||
``` | ||
|
||
where the `status` is a unique non-negative integer thread ID of the new | ||
|
@@ -172,6 +173,43 @@ 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. | ||
|
||
### Thread group | ||
|
||
* The main thread starts with a thread group which only contains | ||
the main thread. | ||
|
||
* Threads created by a thread in a thread group using `wasi_thread_spawn` | ||
is added to the thread group. | ||
|
||
* When a thread is terminated, it's removed from the thread group. | ||
|
||
### Voluntary thread termination | ||
|
||
A thread can terminate itself voluntarily, either by calling | ||
`wasi_thread_exit`, or 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 thread group, not only the calling one. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again just not just drop the |
||
|
||
Any of threads in the thread group can call `proc_exit`. | ||
|
||
### Traps | ||
|
||
When a thread caused a trap, it terminates all threads in the thread group | ||
similarly to `proc_exit`. | ||
|
||
### Thread group exit status | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about |
||
|
||
If one or more threads call WASI `proc_exit` or raise a trap, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does it include calling it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes |
||
one of them is chosen by the runtime to represent the exit status | ||
of the thread group. | ||
It's non deterministic which one is chosen. | ||
|
||
If the thread group gets empty without involving `proc_exit` or 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 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we even need a concept of thread group? Why not just say that
wasi_thread_spawn
creates new threads andwasi_thread_exit
terminates the current thread?The thread group concept seems like something fairly specific to linux and/or the world outside of the process.
If we do want to give a name the container of threads why not use the commonly used term "process"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i just wanted a name for what wasi proc_exit terminates. the name "process" is fine for me too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i renamed it to process.