forked from MightyPork/crsn
more docs, fixes, examples
This commit is contained in:
@@ -1,16 +1,21 @@
|
||||
(
|
||||
; This example shows the use of critical sections.
|
||||
|
||||
; Set short timeslice (50us) to make the effect more pronounced
|
||||
(rt-opt RT_TIMESLICE 50)
|
||||
|
||||
(spawn _ unsafe 'A' 'Z')
|
||||
(spawn _ safe '0' '9')
|
||||
(ssleep 2)
|
||||
(spawn _ unsafe 'a' 'z')
|
||||
(spawn _ safe '0' '9') ; Notice that the sequence 0-9 is always printed in its entirety - because it is in a critical section
|
||||
(msleep 200)
|
||||
(halt)
|
||||
|
||||
(proc unsafe start end
|
||||
; This can be interrupted any time
|
||||
(:x)
|
||||
(yield)
|
||||
(ld r0 start)
|
||||
(:l)
|
||||
(msleep 5)
|
||||
(ld @cout r0)
|
||||
(cmp r0 end)
|
||||
(j.eq :x)
|
||||
|
||||
Reference in New Issue
Block a user