The story so far: process #0, having created a copy of itself in the form of process #1, has gone to sleep. As a result process #1 has become the current process and has returned to “main ”with a value of one. Now read on ...
The statements in “main” which are conditional on “newproc” are now executed:
“expand” (2268) finds a new, larger area (from USIZE*32 to (USIZE+1) *32 words) for process #1, and copies the original data area into it.
In this case, the original user data area consists only of a “per process data area”, with zero length data and stack areas. The original area is released;
“estabur” is used to set the “prototype” segmentation registers which are stored in “u.u_uisa” and “u.u_uisd” for later use by “sureg”. “estabur” calls “sureg” as its last action.
The parameters for “estabur” are the sizes of the text, data and stack areas plus an indicator to decide whether the text and data areas should be in separate address spaces. (Never true on the PDP11/40.) The sizes are all in units of 32 words;
“copyout” (1252) is an assembler routine which copies an array in kernel space of specified size into a region in user space. Here the array “icode” is copied into an area starting at location zero in user space;
The “return” is not special. From “main” it goes to “start” (0670) where the three last instructions have the effect of causing execution in user mode of the instruction at user mode address zero. i.e. the execution of a copy of the first instruction in “icode”. The instructions subsequently executed are copies also of instructions in “icode”.
AT THIS POINT, THE INITIALISATION OF THE SYSTEM IS COMPLETE.
Process #1 is running and to all intents and purposes, is a normal process. Its initial form is (almost) that which would come from compilation, loading and execution of the simple, but non-trivial “C” program:
char *init "/etc/init"; main ( ) { execl (init, init, 0); while (1); }
The equivalent assembler program is
sys exec init initp br . initp: init 0 init: </etc/init\0>
If the system call on “exec” fails (e.g. the file “/etc/init” cannot be found) the process falls into a tight loop, and there the processor will stay, except when the occasional clock interrupt occurs.
A description of the functions performed by “/etc/init” can be found in the section “INIT (VIII)” of the UPM.