forsyth20121205-174063a80cc13 years agoHistory
142 lines · 3.2 KB · Text
RawDownload
.TH KPROC 10.2.SH NAMEkproc, setpri, swiproc, pexit \- kernel process creation, priority change, interrupt and termination.SH SYNOPSIS.ta \w'\fLchar* 'u.Bvoid	kproc(char *name, void (*func)(void*), void *arg, int flags);.PP.Bint	setpri(int pri);.PP.Bvoid	swiproc(Proc *p, int interp);.PP.Bvoid	pexit(char*, int);.SH DESCRIPTION.I Kproccreates a new Inferno kernel processto run the function.IR func ,which is invoked as .BR "(*func)(arg)" .The string.I nameis copied into the.B textfield of the.B Procstructure of the new process; although the value is not visible to Limboapplications, it can appear in system messages written to the console.The process is made runnable; itwill run when selected by the scheduler..PPThe new process always acquires the following attributes from the creating process:.IPowner (Inferno user name).brhost user and group IDs (in.I emuonly).brfloating-point attributes.PPSeveral resources can be shared with the creating process on request, as determined by.IR flags ,which is the logical ORof a subset of the following:.TF KPDUPENVG.TP.B KPDUPPGIf set, the new process shares the caller's process group,which includes its process group ID(for.IR killgrp ),name space (mounts, root and current directory),and PIN for.B /dev/pin(see.IR cons (3))..TP.B KPDUPFDGIf set, the new process shares the caller's file descriptor group;otherwise, it has no file descriptor group, and (if it intends to open files) must call.IR newfgrp (10.2)to obtain an empty file descriptor group..TP.B KPDUPENVGIf set, the new process shares the caller's environment group(currently applies in.I emuonly)..TP.B KPDUPEquivalent to all of the above..PD.PPIf a particular option is not set, the new process will have a.B nilreference for the corresponding resource..PP.I Setprisets the priority of the calling process to.I priand 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:.TF PriBackground.TP.B PriLockThe highest priority, used by.IR lock (10.2)for a process entering a critical section.TP.B PriRealtimeIntended for processes supporting applications with real-time constraints, such as video telephony..TP.B PriHicodecMPEG codec.TP.B PriLocodecAudio codec.TP.B PriHiAny task with keen time constraints..TP.B PriNormalThe priority of most processes in the system..TP.B PriLo.TP.B PriBackground.PD.PP.I Swiprocsends a software interrupt to process.IR p ,causing it to wake from.IR sleep (10.2)with an.IR error (10.2)`interrupted'.Unless.I interpis non-zero (ie, the Dis interpreter is the caller), the process is also marked `killed'..PPAn Inferno process terminates only when it calls.IR 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.IR swiproc .The arguments to.I pexitare ignored in Inferno, but are included for compatibilitywith kernel components of Plan 9; use.IP.EXpexit("", 0);.EE