507 lines · 11.8 KB · Text
RawDownload
.TH PROC 3.SH NAMEproc \- running processes.SH SYNOPSIS.nf.B bind #p /proc.sp 0.3v.B /proc/trace.BI /proc/ n /args.BI /proc/ n /ctl.BI /proc/ n /fd.BI /proc/ n /fpregs.BI /proc/ n /kregs.BI /proc/ n /mem.BI /proc/ n /note.BI /proc/ n /noteid.BI /proc/ n /notepg.BI /proc/ n /ns.BI /proc/ n /proc.BI /proc/ n /profile.BI /proc/ n /regs.BI /proc/ n /segment.BI /proc/ n /status.BI /proc/ n /text.BI /proc/ n /wait\&....fi.SH DESCRIPTIONThe.I procdevice serves a two-level directory structure.The first level contains the.B tracefile (see below) and numbered directoriescorresponding to pids of live processes;each such directory contains a set of filesrepresenting the corresponding process..PPThe.B memfile contains the current memory image of the process.A read or write at offset.IR o ,which must be a valid virtual address,accesses bytes from address.IR oup to the end of the memory segment containing.IR o .Kernel virtual memory, including the kernel stack for the process andsaved user registers (whose addresses are machine-dependent),can be accessed through.BR mem .Writes are permitted only while the process is in the.B Stoppedstate and only to user addresses or registers..PPThe read-only.B procfile contains the kernel per-processstructure.Its main use is to recover the kernel stack and program counterfor kernel debugging..PPThe files.BR regs ,.BR fpregs ,and.BR kregshold representations of the user-level registers, floating-point registers,and kernel registers in machine-dependent form.The.B kregsfile is read-only..PPThe read-only.B fdfile lists the open file descriptors of the process.The first line of the file is its current directory; subsequent lines list, one per line,the open files, giving the decimal file descriptor number; whether the file is open for read.RB ( r ),write,.RB ( w ),or both.RB ( rw );the type, device number, and qid of the file; its I/O unit (the amount of datathat may be transferred on the file as a contiguous piece; see.IR iounit (2)),its I/O offset; and its name at the time it was opened..PPThe read-only.B nsfile contains a textual representation of the process's file name space, in the format of.IR namespace (6)accepted by.B newns(see.IR auth (2)).The last line of the file identifies the current working directory of the process, in the form of a.B cdcommand(see.IR rc (1)).The information in this file is based on the names files had when the name space was assembled,so the names it contains may be inaccessible if the files have been subsequently renamed or rearranged..PPThe read-only.B segmentfile contains a textual display of the memory segmentsattached to the process.  Each line has multiple fields:the type of segment (\c.BR Stack ,.BR Text ,.BR Data ,.BR Bss ,etc.); one-letter flags such as.B Rfor read-only, if any;starting virtual address, in hexadecimal;ending virtual address, and reference count..PPThe read-only.B statusfile contains a string with twelve fields, each followed by a space.The fields are:.IP \-the process name and user name, each 27 characters left justified.IP \-the process state, 11 characters left justified (see.IR ps (1)).IP \-the six 11-character numbers also held in the process's.B #c/cputimefile.IP \-the amount of memory used by the process, except its stack,in units of 1024 bytes.IP \-the base and current scheduling priority, each 11 character numbers.PPThe read-only.B argsfile contains the arguments of the program when it was created by.IR exec (2).If the program was not created by.BR exec ,such as by.IR fork (2),its.B argsfile will be empty.The format of the file is a list of quoted strings suitable for.BR tokenize ;see.IR getfields (2)..PPThe.B textfile is a pseudonym for the filefrom which the process was executed;its main use is to recover the symbol table of the process..PPThe.B waitfile may be read to recoverrecords from the exiting children of the process in the format of.B await(see.IR wait (2)).If the process has no extant children, living or exited,a read of.B waitwill block.It is an error for a process to attempt to read its own.B waitfile when it has no children.When a process's.B waitfile is being read,the process will draw an errorif it attempts an.B awaitsystem call; similarly, if a process is in an.B awaitsystem call, its.B waitfile cannot be read by any process..PPThe read-only.B profilefile contains the instruction frequency count information used for multiprocess profiling; see.B tprofin.IR prof (1).The information is gleaned by sampling the program's user-level program counterat interrupt time..PPStrings written to the.B notefile will be posted as a note to the process(see.IR notify (2)).The note should be less than.B ERRLEN-1characters long;the last character is reserved for a terminating NUL character.A read of at least.B ERRLENcharacters will retrieve the oldest note posted to theprocess and prevent its delivery to the process.The.B notepgfile is similar, but the note will be delivered to all theprocesses in the target process's.I note group(see.IR fork (2)).However, if the process doing the write is in the group,it will not receive the note.The.B notepgfile is write-only..PPThe textual.B noteidfile may be read to recover an integer identifying the note group of the process(see.B RFNOTEGin.IR fork (2)).The file may be written to cause the process to change to another note group,provided the group exists and is owned by the same user..PPThe file.B /proc/tracecan be opened once and read to see trace events from processes that havehad the string.B tracewritten to their.B ctlfile.Each event produces, in native machine format, the.IR pid ,a.IR type ,and a.I "time stamp"(see.B /sys/include/trace.hand.BR /sys/src/cmd/trace.c )...SS Control messagesTextual messages written to the.B ctlfile control the execution of the process.Some require that the process is in a particular stateand return an error if it is not..TP 10n.B stopSuspend execution of the process, putting it in the.B Stoppedstate..TP 10n.B startResume execution of a.B Stoppedprocess..TP 10n.B waitstopDo not affect the process directly but, like all other messages ending with.BR stop ,block the process writing the.B ctlfile until the target process is in the.B Stoppedstate or exits.Also like other.B stopcontrol messages,if the target process would receive a note while the message is pending,it is instead stopped and the debugging process is resumed..TP 10n.B startstopAllow a.B Stoppedprocess to resume, and then do a.B waitstopaction..TP 10n.B hangSet a bit in the process so that,when it completes an.IR exec (2)system call, it will enter the.B Stoppedstate before returning to user mode.This bit is inherited across.IR fork (2)and.IR exec (2)..TP 10n.B "close\ \fInClose file descriptor.I nin the process..TP 10n.B closefilesClose all open file descriptors in the process..TP 10n.B nohangClear the hang bit..TP 10n.B noswapDon't allow this process to be swapped out.  This shouldbe used carefully and sparingly or the system could runout of memory.  It is meant for processes that can't beswapped, like the ones implementing the swap device and forprocesses containing sensitive data..TP 10n.B killKill the process the next time it crosses the user/kernel boundary..TP 10n.B privateMake it impossible to read the process's user memory.This property is inherited on fork, cleared on.IR exec (2),and is not otherwise resettable..TP 10n.B "pri\ \fInSet the base priority for the process to the integer.IR n ..TP 10n.B "wired\ \fInWire the process to processor.IR n ..TP 10n.B traceWithout an argument, toggle trace event generation for this process into.B /proc/trace(see below).With a zero argument, tracing for the proc is turned off, with a non-zero numericargument, it is turned on..TP 10n.B "period\ \fInuSet the real-time scheduling period of the process to.IR nu ,where.I nis an optionally signed number containing an optional decimal point and.I uis one of.BR s ,.BR ms ,.BR us ,.BR µs ,.BR ns ,orempty.  The time is interpreted, respectively, as.IR seconds ,.IR milliseconds ,.IR microseconds ,.IR microseconds ,.IR nanoseconds ,or, in the case of an absent units specifier, as.IR nanoseconds .If the time specifier is signed, it is interpreted as an increment or decrementfrom a previously set value.  See also the.B admitcommand below..TP 10n.B "deadline\ \fInuSet the real-time deadline interval of the process to.IR nu ,where.I nand.I uare interpreted as for.B periodabove..TP 10n.B "cost\ \fInuSet the real-time cost (maximum CPU time per period) of the process to.IR nu ,where.I nand.I uare interpreted as for.B periodabove..TP 10n.B "sporadicUse sporadic scheduling for the real-time process.  The description of the.B admitcommand below contains further details..TP 10n.B "yieldonblockMake the real-time process yield on blocking I/O.  The description of the.B admitcommand below contains further details..TP 10n.B "admitGiven real-time.IR period ,.I deadlineand.I costare set (an unset.I deadlinewill set.I deadlineto.IR period ),perform a schedulability test and start scheduling the process as a real-timeprocess if the test succeeds.  If the test fails, the.B writewill fail with error set to the reason for failure..TP 10n.B eventAdd a user event to the.B /proc/tracefile..PD..SS Real-time scheduling.I Real-timeprocesses are periodically.IR released ,giving them a higher priority than non-real-time processes until they eithergive up the processor voluntarily, they exhaust their CPU allocation, or they reach their.IR deadline .The moment of release is dictated by the.I periodand whether the process is.I sporadicor not.Non-sporadic processes are called.I periodicand they are released precisely at intervals of their period (but periods can be skippedif the process blocks on I/O).Sporadic processes are released whenever they becomerunnable (after being blocked by.IR sleep ()or I/O), but always at least an interval of.I periodafter the previous release..PPThe.I deadlineof a real-time process specifies that the process must complete within the first.I deadlineseconds of its.IR period .The dealine must be less than or equal to the period.If it is not specified, it is set to the period..PPThe.I costof a real-time process describes the maximum CPU time the process may use per period..PPA real-time process can give up the CPU before its deadline is reachedor its allocation is exhausted.It does this by calling.IR sleep (0).If.I yieldonblockis specified, it also does it by executing any blocking system call..I Yieldonblockis assumed for.I sporadicprocesses..PPOf the released processes,the one with the earliest deadline has the highest priority.Care should be taken using spin locks (see.IR lock (2))because a real-time process spinning on a lock will not give up the processor untilits CPU allocation is exhausted; this is unlikely to be the desired behavior..PPWhen a real-time process reaches its deadline or exhausts its CPU allocation, it remainsschedulable, but at a very low priority..PPThe priority is interpreted by Plan 9's multilevel process scheduler.Priorities run from 0 to 19, with highernumbers representing higher priorities.A process has a base priority anda running priority which is less than or equal to the base priority.As a process uses up more of its allocated time, its priority is lowered.Unlessexplicitly set, user processes have base priority 10, kernel processes13.Children inherit the parent's base priority..SH FILES.nf.B /sys/src/9/*/mem.h.B /sys/src/9/*/dat.h.B /sys/include/trace.h.fi

Lines 1–500 of 507.