-
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 4 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,46 @@ 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 all the threads in the process have been terminated without 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. How about, "If that last running thread in a process terminates without 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's not only about the last running thread. consider a process with two threads.
i think your wording can be interpreted as the exit code of the process can be 0. 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. My my understanding, in your example above Another way of putting it "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.
if things work in a lockstep, maybe.
in that case, i guess you need to say the thread which called 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 it would odd if we allowed any threads to outlive the thread that calls I don't want to hold up this PR, even though I don't love the way this sentence is phrased. I guess we can land this as it stands and try to improve it later. 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. Yeah, let me know if #27 addresses some of the things you bring up here... |
||||||
`proc_exit` or raising a trap, it's treated as if the last thread called | ||||||
`proc_exit` with exit code 0. | ||||||
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. Should we not mention 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 can't imagine any functionalities which even if we avoid mentioning 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.
No, it was only hypothetical question.
Yes |
||||||
|
||||||
#### 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