Skip to content

Commit 5e248d8

Browse files
yamtloganek
authored andcommitted
Clarify how shared memories are created and shared
1 parent 9d4364b commit 5e248d8

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

README.md

+14-9
Original file line numberDiff line numberDiff line change
@@ -128,20 +128,25 @@ TLS bookkeeping (this is not much different than how C starts threads natively).
128128
### Detailed design discussion
129129
130130
Threads are tricky to implement. This proposal relies on a specific WebAssembly
131-
convention in order to work correctly. Upon a call to `wasi_thread_spawn`, the
132-
WASI host must:
131+
convention in order to work correctly.
132+
133+
When instantiating a module which is expected to run with wasi-threads,
134+
the WASI host must:
135+
136+
1. create and provide shared memories to satisfy the module's imports.
137+
138+
Upon a call to `wasi_thread_spawn`, the WASI host must:
139+
133140
1. instantiate the module again — this child instance will be used for the
134141
new thread
135-
2. in the child instance, ensure that any `shared` memories are the same ones as
136-
those of the parent
137-
3. in the child instance, import all of the same WebAssembly objects as the
138-
parent
139-
4. optionally, spawn a new host-level thread (other spawning mechanisms are
142+
2. in the child instance, import all of the same WebAssembly objects,
143+
including the above mentioned shared memories, as the parent
144+
3. optionally, spawn a new host-level thread (other spawning mechanisms are
140145
possible)
141-
5. calculate a positive, non-duplicate thread ID, `tid`, and return it to the
146+
4. calculate a positive, non-duplicate thread ID, `tid`, and return it to the
142147
caller; any error in the previous steps is indicated by returning a negative
143148
error code.
144-
6. in the new thread, call the child instance's exported entry function with the
149+
5. in the new thread, call the child instance's exported entry function with the
145150
thread ID and the start argument: `wasi_thread_start(tid, start_arg)`
146151
147152
A WASI host that implements the above should be able to spawn threads for a

0 commit comments

Comments
 (0)