Here's what I think is the best solution: statically allocate the
maximum number of tasks per process:
struct JobControlBlock { /* the name my OS uses for the info field
of a process (job) */
Task *mainTask; /* task == thread */
Task *jobTasks[400]; /* pointers to entry in an array of statically
allocated tasks */
};
A Task runs a function; it does not continue executing at the current
point. Returning from that function halts the task. Returning from
the main task halts all tasks.
Now a SpawnTask() (fork()) can only be done to create up to 400 tasks
with the exception of the main task.