Implement critical sections and timeslice setting cmd

This commit is contained in:
2020-10-31 21:46:34 +01:00
parent 9cd03ca8e3
commit 735f871ea0
15 changed files with 385 additions and 81 deletions
+39
View File
@@ -0,0 +1,39 @@
(
; This example shows the use of critical sections.
(spawn _ unsafe 'A' 'Z')
(spawn _ safe '0' '9')
(ssleep 2)
(proc unsafe start end
; This can be interrupted any time
(:x)
(ld r0 start)
(:l)
(msleep 5)
(ld @cout r0)
(cmp r0 end)
(j.eq :x)
(inc r0)
(j :l)
)
(proc safe start end
(:again)
(ld r0 start)
; The sequence will always be complete
(crit
(ld @cout ' ') ; space to make it easier to read
(:l)
(ld @cout r0)
(cmp r0 end)
(j.eq :x)
(inc r0)
(j :l)
(:x)
(ld @cout ' ') ; space to make it easier to read
)
(yield)
(j :again)
)
)