-
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
Remove thread IDs #38
Comments
I agree. Having a thread close and another reopen with the same ID sounds like a race condition just waiting to happen. |
I think for the Web thread handle can be a reference to Worker object. |
i'm not sure what's the motivation. |
Thread IDs are a design mistake and many OSes are moving away from them (e.g. pidfd on Linux, HANDLE on Windows). The main issue is that the lifetime of a thread ID is tied to the lifetime of a thread: if a thread exits, the thread ID can be reused for another thread.
The main motivation for host-generated thread IDs is to allow these to be used with hypothetical future WASI syscalls such as
thread_setpriority
. A better way to support this would be to havewasi_thread_spawn
return a thread handle instead of a thread ID. The main differences are:If a unique thread ID is still required for internal use (e.g. futexes) then this should be allocated by wasi-libc using an atomic counter (for example) and passed to
wasi_thread_spawn
as part of the thread's initial state. There is no need to get the host involved in this. wasi-libc can keep a thread handle inpthread_t
for any syscalls that require a thread handle.The text was updated successfully, but these errors were encountered: