File tree Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -149,14 +149,29 @@ variety of languages.
149149
150150### TID (thread ID)
151151
152- TID is a 32-bit integer provided by the host to identify threads created
153- with `wasi_thread_spawn`.
152+ TID is a 32-bit integer to identify threads created with `wasi_thread_spawn`.
153+
154+ * TIDs are managed and provided by host.
154155
155156* TID 0 is reserved. `wasi_thread_spawn` should not return this value.
156157
158+ * It's widely assumed in musl/wasi-libc.
159+
157160* The upper-most 3-bits of TID are always 0.
158161 `wasi_thread_spawn` should not return values with these bits set.
159162
163+ * The most significant bit is the sign bit. As `wasi_thread_spawn` uses
164+ signed integer and uses negative values to indicate errors, a TID needs
165+ to be positive.
166+
167+ * The second bit need to be 0 in order to be compatible with the TID-based
168+ locking implementation in musl/wasi-libc.
169+
170+ * The third bit need to be 0 in order to make an extra room for other
171+ reserved values in wasi-libc.
172+ For example, it can be used to indicate the main thread, which doesn't
173+ have a TID in the current version of this proposal.
174+
160175#### Design choice: pthreads
161176
162177One of the goals of this API is to be able to support `pthreads` for C compiled
You can’t perform that action at this time.
0 commit comments