Use atomic wait/notify on RXTAIL in KEY
This commit is contained in:
19
wipforth.wat
19
wipforth.wat
@@ -628,15 +628,24 @@
|
||||
;; Serial I/O
|
||||
|
||||
(func $key (local $head i32)
|
||||
global.get $RXHEAD
|
||||
i32.atomic.load8_u
|
||||
local.tee $head
|
||||
|
||||
;; Wait for RXBUF to be non-empty
|
||||
loop $wait
|
||||
global.get $RXHEAD
|
||||
i32.atomic.load8_u
|
||||
local.tee $head
|
||||
loop $wait (param i32)
|
||||
global.get $RXTAIL
|
||||
i32.atomic.load8_u
|
||||
i32.eq
|
||||
br_if $wait
|
||||
if
|
||||
global.get $RXTAIL
|
||||
local.get $head
|
||||
i64.const -1
|
||||
memory.atomic.wait32
|
||||
|
||||
local.get $head
|
||||
br $wait
|
||||
end
|
||||
end
|
||||
|
||||
;; Read byte at head position
|
||||
|
||||
Reference in New Issue
Block a user