Skip to content

Commit bd11f75

Browse files
committed
Document how TIDs are to be returned
In WebAssembly/wasi-libc#325, we decided that, to avoid an extra `wait`/`notify` handshake between the parent and child thread, the host-generated TID would be passed not only to the child thread in a `wasi_thread_start` parameter but also returned to the parent thread as the result of `wasi_thread_spawn`. This change documents that decision in the spec.
1 parent ad710e1 commit bd11f75

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ The host implementing `wasi_thread_spawn` will call a predetermined function
9494
export (`wasi_thread_start`) in a new WebAssembly instance. Any necessary
9595
locking/signaling/thread-local storage will be implemented using existing
9696
instructions available in WebAssembly. Ideally, users will never use
97-
`thread_spawn` directly but rather compile their threaded code from a language
98-
that supports threads (see below).
97+
`wasi_thread_spawn` directly but rather compile their threaded code from a
98+
language that supports threads (see below).
9999
100100
#### Use case: support various languages
101101
@@ -135,7 +135,9 @@ WASI host must:
135135
parent
136136
4. optionally, spawn a new host-level thread (other spawning mechanisms are
137137
possible)
138-
5. calculate a non-duplicate thread ID, `tid`
138+
5. calculate a positive, non-duplicate thread ID, `tid`, and return it to the
139+
caller; any error in the previous steps is indicated by returning a negative
140+
error code.
139141
6. in the new thread, call the child instance's exported entry function with the
140142
thread ID and the start argument: `wasi_thread_start(tid, start_arg)`
141143

0 commit comments

Comments
 (0)