-
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 all 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` | ||
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, | ||
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.
How about simply "When
proc_exit
is called the entire process is terminated, including all running threads". I'm not we need the "takes extra responsibility" wording.It seems fairly clear from its name that
proc_exit
would do this, so I don't really see it as "extra responsibility", but maybe thats just my reading of it.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.
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 comment
The 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
proc_exit
brings down the entire process (that is that theproc
part means), even without wasi-threads. It just happens that there was only ever one thread previously.)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.
maybe. i wanted to somehow emphasize that this is something a runtime needs to implement.