CoreForth-0

common/multitasking.ft.md


Simple cooperative multitasking

Cooperative multitasking based on eForth and hForth ideas. A task uses three variables and has own parameter and return stacks.

The user pointer contains the address of the task specific data area

variable up

Address of the action to take when activating the task. At this point, only the wake action is defined.

: status        up @ ;

Address of the status word of the next task.

: follower      up @ cell + ;

Top of the parameter stack.

: tos           up @ 2 cells + ;

Suspend the current task and perform the action (wake for now) of the next task:

Default action for a task: