Plan B User's Manual


proc ­ Processor boxes.




The /b/proc box supplies processing services for the system. Each process has a box under /b/proc on a Plan B machine. Boxes under /b/proc have names that determine the process name. To avoid name collissions, the shell creates boxes named /b/proc/program.N where N is a random number.

The special name /b/proc/me maps to the box for the process that evaluates the name—beware of this when using the shell. To access the shell's own box from the command line use the shell variable $me.

New processes can be created by using make(2) and existing ones can be killed by using delete(2).

Each process box has inner boxes representing process resources. Although kernel processes have their boxes listed in /b/proc, they don't have all the inner boxes that are customary for user processes.
name     is the box containing the name of the process box. This is useful to obtain the real box name for so that a process could obtain a name that is portable to others.
args     is the box containing the arguments of the process; i.e. its command-line.
stat     contains a string with the process status. Newly created processes are said to be born, while ready/running processes are said to be alive. Other states are dead, for faulting processes, paused, for stopped processes, and debugged, for traced processes.
regs     contains the set of register values for the process. The format is a set two-digit string (dec) with the size of the machine word followed by a two-digit string (dec) with the number of registers and by either 8 or 16 digit strings (hexa) with the register values. A copy to regs supplying values for the first and

third registers (convenionally, program counter and first argument) can be used to stablish the starting address and argument for a new process when it shares the address space with the parent.
usr      contains a string with the name of the user responsible for the process. The name is the same used under /b/usr for the same human.

Besides the ones listed above, user processes also have these inner boxes:
prog     is used to contain the program executed by the process. A newly created process starts in born state and does not run until a binary box is either linked or copied to its prog box (or until the program is supplied by linking the whole address space). Only programs within the same node can be linked. events   is used to post events related to the process as well as to control event handling. A process can write to its own event box the strings die to die after any event post, catch to cause event posts to raise an error instead, and ignore to cause event posts to be ignored. Events are posted by copying a string

representing the event to the event box. Any process can post events provided it has permission to copy them and the system itself may post events. Special system events starting with die: can not be catched or ignored, and cause inmediate process death. To arrange for a timeout event to be sent in the future (after n milliseconds), a process can copy a tmout n event to its event box. A periodic timer can be set in the same way by posting a tick n event.
del      is a box that contains names for boxes that the system should delete(2) if the process dies. When a box is created with the Pdeldie permission bit set, the system writes its name to the del box of the process. The user can copy more names into it (one at a time).
legacy   is the process legacy. A process is expected to write an error string (null is no error) to its legacy box. By default, legacy is the same of /b/sys/null and the process legacy is ignored. While the process is born, legacy can be linked to a more appropriate place.
vm       is the outter box for the process virtual memory boxes. Virtual memory boxes are described in vm(4). A copy(2) from another vm box can be used to clone an address space. A link(2) from another vm box can be used to share the address space. Only address space boxes within the same node can be
linked. Both operations are allowed only while the process is born. Before linking, the user should setup regs with the desired entry point for the new process, because the process starts running as soon as the address space is linked.
ns       contains a textual representation of the process name space. Each import is described on a separate line. The box exists not just for informative purposes, a copy(2) from another ns box can be used to clone a name space; A link(2) from another ns box can be used to share the name space. Only name
space boxes within the same node can be linked. Both operations are allowed only while the process is born.
ioN      boxes (where N is conventionally a number) represent the set of stardard I/O boxes used by the process. Number 0 is used for text input, number 1 for text output, and number 2 for text errors; besides number 3 is for pointer input, and number 4 is for graphics output. These boxes are linked to
appropriate places by the shell, according to the usr(4) device. Redirection at run time can be performed by relinking them.


/b/proc as /proc.


/src/b/port/procbox.c and /src/b/*/proc.c.

See also



Inne box regs is not fully implemented. That is not expected to be done before starting the native port of the system. Some special events are expected to appear after adding debugging facilities to Plan B.

If a box is noted to be removed when the process dies, and an error forbids the removal during process deletetion, the box may survive the process.

The conventions for I/O boxes are undergoing severe changes.

Plan B User's Manual. First edition.