Hello Matthias,

I am pleased to advise that I managed "to marry" in amforth-shadow (#1)
Multitasking with Soft-Interrupts (#2) and have the advantage of the two
worlds (synchronous and asynchronous processings, respectively).

As with my previous works, I will be honored if you would include some
of my code into your project.

Sincerely, Enoch.

#1 https://github.com/wexi/amforth-shadow
#2 aka Second Level Interrupt Handling (SLIH)

----------------------------------------------------------------------

4 lib/tasks.frt

This is a major rewrite of lib/multitask.frt that is compatibile with
AmForth-Shadow Soft Interrupts (SLIH) and has some minor enhancements
such as the addition of task names.

\ initialize "main" as a running task. MUST BE CALLED FIRST!
tasks-init ( -- )

\ allocate task memory. Store task>parameters in dictionary.
task: ( R-stack-bytes D-stack-bytes User-app-bytes "task-name" -- )

\ initialize task in memory: ITC is some endless code with pauses. TASK
\ is the task name.
task-init ( ITC TASK -- )

\ enable TASK.
task-run ( TASK -- )

\ is the task running?
task-run? ( TASK -- flag )

\ disable TASK
task-stop ( TASK -- )

\ disable multitasking
tasks-off ( -- )

\ enable multitasking
tasks-on ( -- )

\ display all tasks.
tasks ( -- )

\ Add a simple example task:

80 160 0 task: greet

dp ]
5 7 13 17
begin
   pause
again
[ constant hello

hello greet task-init
greet task-run

tasks

*main   559 running
 greet  1448 running@12762 D#4 17 13 7 
 bkgd   1094 stopped@11348 D#0 
tasks: on

\ "greet" is the newly created task name. This task inherits its
\ definitions from the "main" task, its creator (i.e., inherits the
\ deferred words key, emit, etc). "1448" is the starting address
\ of the task memory (that is 30+160+80 bytes long). "12762" is the IP
\ following "pause". "greet" has 4 numbers on its D-stack where the
\ topmost 3 are displayed.



------------------------------------------------------------------------------
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
Amforth-devel mailing list for http://amforth.sf.net/
Amforth-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/amforth-devel

Reply via email to