-
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 3 commits
2b7fb32
ccc5811
ec8172d
dc1ac30
f74d69d
c732034
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -172,6 +172,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` | ||||||
is 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. | ||||||
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 simply "When It seems fairly clear from its name that 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. without wasi-threads, a runtime would simply terminate the calling thread. when adding wasi-threads support to a runtime, you need to make it terminate other thread too. it would need a significant implementation effort. i feel it's appropriate to call it extra. 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. Sure. But don't think that is clear enough to simply say: "When proc_exit is called the entire process is terminated, including all running threads". (BTW, the way I see 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. maybe. i wanted to somehow emphasize that this is something a runtime needs to implement. |
||||||
|
||||||
Any of threads in the process can call `proc_exit`. | ||||||
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.
Suggested change
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. done |
||||||
|
||||||
### Traps | ||||||
|
||||||
When a thread caused a trap, it terminates all threads in the process | ||||||
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. s/caused/causes/ ? How about "When a trap occurs in any thread, the entire process is terminated."? 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.
probably. i'm not good at english as you may noticed.
done. |
||||||
similarly to `proc_exit`. | ||||||
|
||||||
### Process exit status | ||||||
|
||||||
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 process. | ||||||
It's non deterministic which one is chosen. | ||||||
|
||||||
If the process gets empty without involving `proc_exit` or 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. "gets empty" sounds a little odd to me. How about "If the last remaining thread in the process returns from its entry point without trapping or calling 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. it isn't only about the last thread. also, i want to avoid mentioning the entry point in this sentence because it can involve another topic: #21 how about:
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. Sure thats sounds fine. Perhaps we can define "normal termination" and "early termination" and say "If all the threads in the process terminate normally"? 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.
done
i feel it confusing as calling exit() is quite normal. 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. I think its reasonable to refer to "exit()" as early and/or abnormal termination. |
||||||
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.
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.
done