Skip to content
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

wasi-threads: fix use of wait in test #5858

Merged
merged 1 commit into from
Feb 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions tests/all/cli_tests/threads.wat
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,15 @@
(drop (call $__wasi_thread_spawn (i32.const 0)))

;; Wait for all the threads to notify us that they are done.
(local.set $i (i32.const 0))
(loop $again
;; Retrieve the i32 at address 128, compare it to -1 (it should always
;; fail) and load it atomically to check if all three threads are
;; complete. This wait is for 1ms or until notified, whichever is first.
(drop (memory.atomic.wait32 (i32.const 128) (i32.const -1) (i64.const 1000000)))
(br_if $again (i32.lt_s (i32.atomic.load (i32.const 128)) (i32.const 3)))
;; Wait for the i32 at address 128 to be incremented by each thread. We
;; maintain a local $i with the atomically loaded value as the expected
;; wait value and to check if all three threads are complete. This wait is
;; for 1ms or until notified, whichever is first.
(drop (memory.atomic.wait32 (i32.const 128) (local.get $i) (i64.const 1000000)))
(local.set $i (i32.atomic.load (i32.const 128)))
(br_if $again (i32.lt_s (local.get $i) (i32.const 3)))
)

;; Print "Done".
Expand Down