XINU Process Creation Primitives

XINU Process Creation Primitives

The XINU primitive for process creation is similar to that of PThreads.

pid = create (sub_addr, stack_size, priority, name, number_of_args, arg1, arg2, ...)
This creates a new process with the entry point being the subroutine "sub_addr". In XINU, new processes are created in the SUSPEND state (not ready as in PThreads). Thus, to allow a process to run, you must call resume(pid).

For example:

#include <conf.h>
main()
    {
    int prA(), prB();
    resume( create (prA, 12000, 20, "pra", 0 ) );
    resume( create (prB, 12000, 20, "prb", 0 ) );
    }
prA() {while(1) putc(CONSOLE, 'A'); }
prB() {while(1) putc(CONSOLE, 'B'); }

This creates two concurrent processes - one spewing A's, and the other spewing B's.

A process will go away (die)

1