Adding tasks.
This commit is contained in:
@ -71,7 +71,8 @@ $(GEN):
|
||||
|
||||
POSIX_BOOT = common/boot.fs common/terminal.fs \
|
||||
posix/posix.fs posix/posix_highlevel.fs \
|
||||
common/filetools.fs posix/posix_desktop.fs
|
||||
common/filetools.fs posix/posix_desktop.fs \
|
||||
common/tasks.fs
|
||||
$(GEN)/posix_boot.h: common/source_to_string.js $(POSIX_BOOT) | $(GEN)
|
||||
echo "ok" | cat $(POSIX_BOOT) - | $< boot >$@
|
||||
|
||||
@ -81,7 +82,7 @@ $(GEN)/windows_boot.h: common/source_to_string.js $(WINDOWS_BOOT) | $(GEN)
|
||||
|
||||
ARDUINO_BOOT = common/boot.fs arduino/arduino.fs \
|
||||
posix/posix_highlevel.fs common/filetools.fs \
|
||||
arduino/arduino_server.fs \
|
||||
common/tasks.fs arduino/arduino_server.fs \
|
||||
arduino/autoboot.fs
|
||||
$(GEN)/arduino_boot.h: common/source_to_string.js $(ARDUINO_BOOT) | $(GEN)
|
||||
echo "ok" | cat $(ARDUINO_BOOT) - | $< boot >$@
|
||||
|
||||
30
ueforth/common/tasks.fs
Normal file
30
ueforth/common/tasks.fs
Normal file
@ -0,0 +1,30 @@
|
||||
( Cooperative Tasks )
|
||||
|
||||
variable task-list
|
||||
|
||||
: add-task ( t -- )
|
||||
task-list @ if
|
||||
task-list @ @ over !
|
||||
task-list @ !
|
||||
else
|
||||
dup task-list !
|
||||
dup !
|
||||
then
|
||||
;
|
||||
|
||||
: task ( xt rsz dsz "name" )
|
||||
create here >r 0 , 0 , 0 ,
|
||||
here cell+ r@ cell+ ! cells allot
|
||||
here r@ 2 cells + ! cells allot
|
||||
dup 0= if drop else >:body r@ 2 cells + @ ! then
|
||||
r> add-task ;
|
||||
|
||||
: pause
|
||||
rp@ task-list @ 2 cells + !
|
||||
sp@ task-list @ cell+ !
|
||||
task-list @ @ task-list !
|
||||
task-list @ cell+ @ sp!
|
||||
task-list @ 2 cells + @ rp!
|
||||
;
|
||||
|
||||
0 0 0 task main-task
|
||||
@ -32,6 +32,7 @@ z" rename" 2 sysfunc rename
|
||||
z" malloc" 1 sysfunc malloc
|
||||
z" free" 1 sysfunc sysfree
|
||||
z" realloc" 2 sysfunc realloc
|
||||
z" usleep" 1 sysfunc usleep
|
||||
|
||||
( Errno )
|
||||
z" __errno_location" 0 sysfunc __errno_location
|
||||
@ -95,3 +96,6 @@ octal 777 constant 0777 decimal
|
||||
dup 0 SEEK_CUR lseek >r
|
||||
dup 0 SEEK_END lseek r> swap >r
|
||||
SEEK_SET lseek drop r> 0<ior ;
|
||||
|
||||
( Other Utils )
|
||||
: ms ( n -- ) 1000 * usleep drop ;
|
||||
|
||||
Reference in New Issue
Block a user