|
John,
You might want to try this little script to try out the tasker.
It's based on Koh's demo. If you type
TASK0 AWAKE and then .TASKS, you will see the chain is ok and that
TASK0 is running.
Now press the RUN button on the RCX and try .TASKS again.
TASK0 is now sleeping...neat!
One other point worth mentioning is that you can move the RCX_BUTTON @ 1 = STOP
code to a different task, and as long as TASK0 is running, and sampling the keypad,
another task can be stopped! This is one of the reasons I changed BUTTON_GET to
not return the button state...
<--- script starts here
\
\ Multitasker Demo Program
\
\ This demo is very crude, however, it shows hForth's multitasking ability.
\
\ Reserve enough space for data and return stack for each task.
\ Data stack and return stack seems to be at lease 50 CELLS deep for MS-DOS.
\
\ 1995. 5. 1.
\ By Wonyong Koh
BASE @ DECIMAL
0 32 CELLS 32 CELLS HAT TASK0
0 32 CELLS 32 CELLS HAT TASK1
0 32 CELLS 32 CELLS HAT TASK2
0 32 CELLS 32 CELLS HAT TASK3
TASK0 BUILD
TASK1 BUILD
TASK2 BUILD
TASK3 BUILD
HEX
RCX_INIT
BUTTON_INIT
:NONAME TASK0 ACTIVATE BEGIN 400 0 DO PAUSE LOOP
RCX_BUTTON 3000 BUTTON_GET
RCX_BUTTON @ 1 = IF STOP THEN
AGAIN ; EXECUTE
:NONAME TASK1 ACTIVATE BEGIN 800 0 DO PAUSE LOOP AGAIN ; EXECUTE
:NONAME TASK2 ACTIVATE BEGIN 1000 0 DO PAUSE LOOP AGAIN ; EXECUTE
:NONAME TASK3 ACTIVATE BEGIN 2000 0 DO PAUSE LOOP AGAIN ; EXECUTE
TASK0 SLEEP
TASK1 SLEEP
TASK2 SLEEP
TASK3 SLEEP
BASE !
<--- script ends here
Cheers,
Ralph Hempel - P.Eng
--------------------------------------------------------
Check out pbFORTH for LEGO Mindstorms at:
<http://www.bmts.com/~rhempel/lego/pbFORTH/default.html>
--------------------------------------------------------
Reply to: rhempel at bmts dot com
------------------------------------------------------
|
|
Message has 1 Reply: | | RE: Multitasker test script
|
| Previously, I wrote (...) If anyone else out there is tempted to try the pbFORTH tasker, I will email the srec to you. I have not posted it on my website because it is very early beta software. Cheers, Ralph Hempel - P.Eng ---...--- Check out (...) (26 years ago, 12-May-99, to lugnet.robotics.rcx.pbforth)
|
9 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|