Annotation of researchv10dc/man/adm/man9/newproc.9, revision 1.1.1.1

1.1       root        1: .TH NEWPROC 9.2
                      2: .CT 2 proc_man
                      3: .SH NAME
                      4: P, newproc, muxnewwind, newwindow, tolayer, debug, getproc, getproctab, putname, getname \- jerq process control
                      5: .SH SYNOPSIS
                      6: .B #include <jerq.h>
                      7: .PP
                      8: .B extern struct Proc *P;
                      9: .PP
                     10: .B struct Proc *newproc(f)
                     11: .B void (*f)();
                     12: .PP
                     13: .B struct Proc *newwindow(f);
                     14: .B void (*f)();
                     15: .PP
                     16: .B void tolayer(l)
                     17: .B Layer *l;
                     18: .PP
                     19: .B void debug();
                     20: .PP
                     21: .B struct Proc *getproc();
                     22: .PP
                     23: .B struct Proc *getproctab();
                     24: .PP
                     25: .B int putname(string, data)
                     26: .B char *string; long data;
                     27: .PP
                     28: .B struct Nqueue *getname(string)
                     29: .B char *string;
                     30: .PP
                     31: .B #include <msgs.h>
                     32: .br
                     33: .B void muxnewwind(p, c)
                     34: .B struct Proc *p; int c;
                     35: .SH DESCRIPTION
                     36: Processes in the jerq consist of a coroutine-style process
                     37: structure and an associated layer
                     38: (see
                     39: .IR newlayer (9.2)),
                     40: allocated independently.
                     41: This section describes the process allocation and control
                     42: primitives.
                     43: They are direct links to the system's own
                     44: control structures, so given
                     45: .IR mux 's
                     46: open addressing, they should be used with care.
                     47: .PP
                     48: Each process has a global variable
                     49: .I P
                     50: that points to its process structure.
                     51: The only regular use of
                     52: .I P
                     53: is to check that the process has been moved or reshaped:
                     54: .IP
                     55: .EX
                     56: if(P->state & RESHAPED){
                     57:        do_reshape();
                     58:        P->state &= ~RESHAPED;
                     59: }
                     60: .EE
                     61: .PP
                     62: The definition of
                     63: .B struct Proc
                     64: is in the include file
                     65: .BR <jerqproc.h> ,
                     66: which is included automatically by
                     67: .BR <jerq.h> .
                     68: .PP
                     69: .I Newproc
                     70: allocates a new process, returning a pointer to it, or 0
                     71: if one cannot be allocated.
                     72: Argument
                     73: .I f
                     74: points to the program text to be executed.
                     75: The special case
                     76: .IR f =0
                     77: creates a process running the default terminal program,
                     78: and is almost always how
                     79: .I newproc
                     80: should be called; use
                     81: .IR 32ld (9.1)
                     82: to run non-standard programs.
                     83: A process is disabled by setting
                     84: .I p->state
                     85: to zero.
                     86: After calling
                     87: .IR newproc,
                     88: the process must be bound to a layer and
                     89: Unix told of its presence, typically as:
                     90: .IP
                     91: .EX
                     92: struct Proc *p;
                     93: Rectangle r;
                     94: p = newproc((struct Proc *)0);
                     95: if(p == 0)
                     96:        error();
                     97: p->layer = newlayer(r);
                     98: if(p->layer == 0){
                     99:        p->state = 0;
                    100:        error();
                    101: }
                    102: p->rect = r;
                    103: muxnewwind(p, C_NEW);
                    104: .EE
                    105: .PP
                    106: The second argument to
                    107: .I muxnewwind
                    108: should be
                    109: .B C_RESHAPE
                    110: if an existing process is being given a new layer.
                    111: If the process is
                    112: .I not
                    113: running the default terminal program, its variables
                    114: .L display
                    115: and
                    116: .L Drect
                    117: must be set:
                    118: .IP
                    119: .EX
                    120: struct udata *u=((struct udata *)p->data);
                    121: u->Drect=p->rect;
                    122: u->Jdisplayp=p->layer;
                    123: .EE
                    124: This procedure works regardless of whether the process being manipulated is itself.
                    125: .PP
                    126: .I Newwindow
                    127: creates a process by the above procedure, going through the
                    128: standard user interface to select the rectangle for the process's
                    129: layer.
                    130: .PP
                    131: .I Tolayer
                    132: takes an argument
                    133: .I layer
                    134: pointer and makes the process in that layer the receiver of
                    135: mouse and keyboard events.
                    136: .PP
                    137: .I Getproc
                    138: presents the user with a gunsight cursor and returns the
                    139: address of the process whose layer is indicated with the mouse.
                    140: .I Getproctab
                    141: simply returns the address of the base of the process table array.
                    142: This is an array of
                    143: .B NPROC
                    144: process structures.
                    145: .B NPROC
                    146: is stored in the word immediately lower in address than the
                    147: process table.
                    148: .PP
                    149: .I Debug
                    150: announces to the system that the calling process is prepared
                    151: to handle exceptions by other processes.
                    152: .PP
                    153: .I Putname
                    154: and 
                    155: .I getname
                    156: manage a bulletin board for interprocess communication.
                    157: Further communication may be arranged through shared memory.
                    158: .I Putname
                    159: associates
                    160: .I data
                    161: with
                    162: .I string,
                    163: returning nonzero normally, or 0 if the data could not be stored.
                    164: .I Getname
                    165: returns a pointer 
                    166: to a structure which contains
                    167: .TP
                    168: .B struct Proc *proc
                    169: pointer to the process structure of the layer that
                    170: most recently announced the string
                    171: .TP
                    172: .B long data
                    173: the corresponding data
                    174: .LP
                    175: .I Getname
                    176: returns 0 if no such string has been announced.
                    177: A pointer returned by
                    178: .I getname
                    179: remains valid: a client may rendezvous with a server by
                    180: calling
                    181: .I getname
                    182: once and repeatedly testing
                    183: the associated
                    184: .B proc
                    185: pointer thereafter.
                    186: .SH BUGS
                    187: These primitives are awkward at best, and are
                    188: subject to change.
                    189: .br
                    190: Creating a process without a layer or
                    191: .I
                    192: vice versa
                    193: is dangerous.

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.