aboutsummaryrefslogtreecommitdiff
path: root/amforth-6.5/common/lib/multitask-test.frt
diff options
context:
space:
mode:
Diffstat (limited to 'amforth-6.5/common/lib/multitask-test.frt')
-rw-r--r--amforth-6.5/common/lib/multitask-test.frt44
1 files changed, 44 insertions, 0 deletions
diff --git a/amforth-6.5/common/lib/multitask-test.frt b/amforth-6.5/common/lib/multitask-test.frt
new file mode 100644
index 0000000..8574bb9
--- /dev/null
+++ b/amforth-6.5/common/lib/multitask-test.frt
@@ -0,0 +1,44 @@
+
+\ load the multitasker
+\ #require multitask.frt
+
+: 1ms 1000 0 do 500 0 do loop loop ;
+
+: ms ( n -- ) \ call pause on wait
+ pause 0 ?do 1ms loop ;
+
+ \ create a persistent task
+variable N
+: init
+ 0 N !
+;
+\ --- task 2 ---
+: demo-task
+ begin
+ 1 N +!
+ &500 ms
+ again ;
+
+$40 $40 0 task: task_demo \ allocate task data space
+
+: setup-demo-task
+ task_demo tib>tcb
+ activate \ words after this line are run in new task
+ demo-task
+;
+
+: starttasker
+ task_demo task-init \ create TCB in RAM
+ setup-demo-task \ activate tasks job
+
+ onlytask \ make cmd loop task-1
+ task_demo tib>tcb alsotask \ start task-2
+ multi \ activate multitasking
+;
+\ make this the turnkey vector
+\
+: task-turnkey
+ applturnkey
+ init
+ starttasker
+;