Manual Page Result
0
Command: newproc | Section: 9 | Source: UNIX v10 | File: newproc.9
NEWPROC(9.2) NEWPROC(9.2)
NAME
P, newproc, muxnewwind, newwindow, tolayer, debug, getproc, getproctab,
putname, getname - jerq process control
SYNOPSIS
#include <jerq.h>
extern struct Proc *P;
struct Proc *newproc(f) void (*f)();
struct Proc *newwindow(f); void (*f)();
void tolayer(l) Layer *l;
void debug();
struct Proc *getproc();
struct Proc *getproctab();
int putname(string, data) char *string; long data;
struct Nqueue *getname(string) char *string;
#include <msgs.h>
void muxnewwind(p, c) struct Proc *p; int c;
DESCRIPTION
Processes in the jerq consist of a coroutine-style process structure
and an associated layer (see newlayer(9.2)), allocated independently.
This section describes the process allocation and control primitives.
They are direct links to the system's own control structures, so given
mux's open addressing, they should be used with care.
Each process has a global variable P that points to its process struc-
ture. The only regular use of P is to check that the process has been
moved or reshaped:
if(P->state & RESHAPED){
do_reshape();
P->state &= ~RESHAPED;
}
The definition of struct Proc is in the include file <jerqproc.h>,
which is included automatically by <jerq.h>.
Newproc allocates a new process, returning a pointer to it, or 0 if one
cannot be allocated. Argument f points to the program text to be exe-
cuted. The special case f=0 creates a process running the default ter-
minal program, and is almost always how newproc should be called; use
32ld(9.1) to run non-standard programs. A process is disabled by set-
ting p->state to zero. After calling newproc, the process must be
bound to a layer and Unix told of its presence, typically as:
struct Proc *p;
Rectangle r;
p = newproc((struct Proc *)0);
if(p == 0)
error();
p->layer = newlayer(r);
if(p->layer == 0){
p->state = 0;
error();
}
p->rect = r;
muxnewwind(p, C_NEW);
The second argument to muxnewwind should be C_RESHAPE if an existing
process is being given a new layer. If the process is not running the
default terminal program, its variables and must be set:
struct udata *u=((struct udata *)p->data);
u->Drect=p->rect;
u->Jdisplayp=p->layer;
This procedure works regardless of whether the process being ma-
nipulated is itself.
Newwindow creates a process by the above procedure, going through the
standard user interface to select the rectangle for the process's
layer.
Tolayer takes an argument layer pointer and makes the process in that
layer the receiver of mouse and keyboard events.
Getproc presents the user with a gunsight cursor and returns the ad-
dress of the process whose layer is indicated with the mouse. Get-
proctab simply returns the address of the base of the process table ar-
ray. This is an array of NPROC process structures. NPROC is stored in
the word immediately lower in address than the process table.
Debug announces to the system that the calling process is prepared to
handle exceptions by other processes.
Putname and getname manage a bulletin board for interprocess communica-
tion. Further communication may be arranged through shared memory.
Putname associates data with string, returning nonzero normally, or 0
if the data could not be stored. Getname returns a pointer to a struc-
ture which contains
struct Proc *proc
pointer to the process structure of the layer that most recently
announced the string
long data
the corresponding data
Getname returns 0 if no such string has been announced. A pointer re-
turned by getname remains valid: a client may rendezvous with a server
by calling getname once and repeatedly testing the associated proc
pointer thereafter.
BUGS
These primitives are awkward at best, and are subject to change.
Creating a process without a layer or vice versa is dangerous.
NEWPROC(9.2)