Lines Matching refs:thread

19 ;; The main thread will then yield to these threads in the order that they are stored in the buffer,
24 ;; The main thread then ensures that the assigned numbers have been written into the correct locati…
27 ;; Defines the table for the thread start function
30 ;; Defines the thread start function and a function that calls thread.new-indirect
33 (import "" "thread.new-indirect" (func $thread-new-indirect (param i32 i32) (result i32)))
34 (import "" "thread.suspend" (func $thread-suspend (result i32)))
35 … (import "" "thread.yield-to-suspended" (func $thread-yield-to-suspended (param i32) (result i32)))
36 …(import "" "thread.suspend-to-suspended" (func $thread-suspend-to-suspended (param i32) (result i3…
37 (import "" "thread.yield" (func $thread-yield (result i32)))
38 (import "" "thread.index" (func $thread-index (result i32)))
39 (import "" "thread.unsuspend" (func $thread-unsuspend (param i32)))
42 ;; A memory block that threads will write their thread indexes and assigned values into
46 ;; We initialize this to 20 (threads * 4 bytes of storage per thread)
49 … ;; The thread entry point, which writes the thread's index into memory at the assigned location,
50 ;; suspends back to the main thread, then writes the assigned value into memory
51 (func $thread-start (param i32)
52 ;; Store the thread index into the assigned location
53 (i32.store (local.get 0) (call $thread-index))
54 (drop (call $thread-suspend))
58 (export "thread-start" (func $thread-start))
60 ;; Initialize the function table with our thread-start function; this will be
61 ;; used by thread.new-indirect
62 (elem (table $indirect-function-table) (i32.const 0) func $thread-start)
64 (func $new-thread (param i32)
66 (call $thread-yield-to-suspended
67 (call $thread-new-indirect (i32.const 0) (local.get 0)))))
72 (call $new-thread (i32.const 16))
73 (call $new-thread (i32.const 12))
74 (call $new-thread (i32.const 4))
75 (call $new-thread (i32.const 0))
76 (call $new-thread (i32.const 8))
79 (drop (call $thread-yield-to-suspended (i32.load (i32.const 0))))
80 (drop (call $thread-yield-to-suspended (i32.load (i32.const 4))))
81 (drop (call $thread-yield-to-suspended (i32.load (i32.const 8))))
82 (drop (call $thread-yield-to-suspended (i32.load (i32.const 12))))
83 (drop (call $thread-yield-to-suspended (i32.load (i32.const 16))))
97 ;; Get access to `thread.new-indirect` that uses the table from libc
101 (core func $thread-new-indirect
102 (canon thread.new-indirect $start-func-ty (table $indirect-function-table)))
103 (core func $thread-yield (canon thread.yield))
104 (core func $thread-index (canon thread.index))
105 (core func $thread-yield-to-suspended (canon thread.yield-to-suspended))
106 (core func $thread-unsuspend (canon thread.unsuspend))
107 (core func $thread-suspend-to-suspended (canon thread.suspend-to-suspended))
108 (core func $thread-suspend (canon thread.suspend))
114 (export "thread.new-indirect" (func $thread-new-indirect))
115 (export "thread.index" (func $thread-index))
116 (export "thread.yield-to-suspended" (func $thread-yield-to-suspended))
117 (export "thread.yield" (func $thread-yield))
118 (export "thread.suspend-to-suspended" (func $thread-suspend-to-suspended))
119 (export "thread.suspend" (func $thread-suspend))
120 (export "thread.unsuspend" (func $thread-unsuspend))))