multi-tasking
GForth Reference implementation of multi-tasking standard proposal
- raw README.md
- raw atomic.fs
- raw clh.fs
- raw linux-support.fs
- raw mt.fs
- raw multi-tasking.fs
- raw package.4th
- raw posix-support.fs
- raw spinlock.fs
- raw tasks.fs
- raw tests.fs
\ Simple spin locks
\
\ These are best on single-processor round-robin multi-tasking
\ systems.
cell constant /mutex
: mutex-init ( lock -- ) 0 swap atomic! ;
: get ( lock -- )
>r
assert( r@ @ this-task <> )
begin pause 0 this-task r@ atomic-cas 0= until
assert( r@ @ this-task = )
r> drop
;
: release ( lock -- )
assert( dup @ this-task = )
0 swap atomic! ;