| KPROC(10.2) | KPROC(10.2) |
kproc, setpri, swiproc, pexit - kernel process creation, priority change, interrupt and termination
void kproc(char *name, void (*func)(void*), void *arg, int flags);
int setpri(int pri);
void swiproc(Proc *p, int interp);
void pexit(char*, int);
Kproc creates a new Inferno kernel process to run the function func, which is invoked as (*func)(arg). The string name is copied into the text field of the Proc structure of the new process; although the value is not visible to Limbo applications, it can appear in system messages written to the console. The process is made runnable; it will run when selected by the scheduler.
The new process always acquires the following attributes from the creating process:
Several resources can be shared with the creating process on request, as determined by flags, which is the logical OR of a subset of the following:
If a particular option is not set, the new process will have a nil reference for the corresponding resource.
Setpri sets the priority of the calling process to pri and returns its previous priority level. If a (now) higher priority process is ready to run, the system will reschedule. The available priority levels are shown below, arranged from highest to lowest priority, with examples of the type of processes intended to use them:
Swiproc sends a software interrupt to process p, causing it to wake from sleep(10.2) with an error(10.2) `interrupted'. Unless interp is non-zero (ie, the Dis interpreter is the caller), the process is also marked `killed'.
An Inferno process terminates only when it calls pexit, thereby terminating itself. There is no mechanism for one process to force the termination of another, although it can send a software interrupt using swiproc. The arguments to pexit are ignored in Inferno, but are included for compatibility with kernel components of Plan 9; use
pexit("", 0);