;;; -*- Mode:gate; Fonts:(HL12 HL12I HL12B CPTFONTB HL12BI HL12B HL12I ) -*- =Node: 4Process Generic Operations* =Text: 3PROCESS GENERIC OPERATIONS* These are the operations that are defined on all flavors of process. Certain process flavors may define additional operations. Not all possible operations are listed here, only those of interest to the user. =Node: 4Process Attributes* =Text: 3PROCESS ATTRIBUTES :name* 1Operation on 2si:process** Returns the name of the process, which was the first argument to 2make-process* or 2process-run-function* when the process was created. The name is a string that appears in the printed-representation of the process, stands for the process in the who-line and the 2peek* display, etc. 3:stack-group* 1Operation on 2si:process** Returns the stack group currently executing on behalf of this process. This can be different from the initial-stack-group if the process contains several stack groups that coroutine among themselves, or if the process is in the error-handler, which runs in its own stack group. Note that the stack-group of a 1simple* process (see 4(PROCESSES-1)Process Flavors*) is not a stack group at all, but a function. 3:initial-stack-group* 1Operation on 2si:process** Returns the stack group the initial-function is called in when the process starts up or is reset. 3:initial-form* 1Operation on 2si:process** Returns the initial ``form'' of the process. This isn't really a Lisp form; it is a cons whose car is the initial-function and whose cdr is the list of arguments to which that function is applied when the process starts up or is reset. In a simple process (see 4(PROCESSES-1)Process Flavors*), the initial form is a list of one element, the process's function. To change the initial form, use the 2:preset* operation (see ). 3:wait-function* 1Operation on 2si:process** Returns the process's current wait-function, which is the predicate used by the scheduler to determine if the process is runnable. This is 2#'true* if the process is running, and 2#'false* if the process has no current computation (for instance, if it has just been created, its initial function has returned) or if the program has decided to wait indefinitely. The wait-function of a flushed process is 2si:flushed-process*, a function equivalent to 2#'false* but recognizably distinct. 3:wait-argument-list* 1Operation on 2si:process** Returns the arguments to the process's current wait-function. This is frequently the 2&rest* argument to 2process-wait* in the process's stack. The system always uses it in a safe manner, i.e. it forgets about it before 2process-wait* returns. 3:whostate* 1Operation on 2si:process** Returns a string that is the state of the process to go in the who-line at the bottom of the screen. This is 2"run"* if the process is running or trying to run; otherwise, it is the reason why the process is waiting. If the process is stopped, then this whostate string is ignored and the who-line displays 2arrest* if the process is arrested or 2stop* if the process has no run reasons. 3:quantum* 1Operation on 2si:process** 3:set-quantum* 160ths* 1Operation on 2si:process** Respectively return and change the number of 60ths of a second this process is allowed to run without waiting before the scheduler will run someone else. The quantum defaults to 1 second. 3:quantum-remaining* 1Operation on 2si:process** Returns the amount of time remaining for this process to run, in 60ths of a second. 3:priority* 1Operation on 2si:process** 3:set-priority* 1priority-number* 1Operation on 2si:process** Respectively return and change the priority of this process. The larger the number, the more this process gets to run. Within a priority level the scheduler runs all runnable processes in a round-robin fashion. Regardless of priority a process will not run for more than its quantum. The default priority is 0, and no normal process uses other than 0. 3:warm-boot-action* 1Operation on 2si:process** 3:set-warm-boot-action* 1action* 1Operation on 2si:process** Respectively return and change the process's warm-boot-action, which controls what happens if the machine is booted while this process is active. (Contrary to the name, this applies to both cold and warm booting.) This can be 2nil* or 2:flush*, which means to 1flush* the process (see 4(PROCESSES-1)Bashing the Process*), or can be a function to call. The default is 2si:process-warm-boot-delayed-restart*, which resets the process, causing it to start over at its initial function. You can also use 2si:process-warm-boot-reset*, which throws out of the process' computation and kills the process, or 2si:process-warm-boot-restart*, which is like the default but restarts the process at an earlier stage of system reinitialization. This is used for processes like the keyboard process and chaos background process, which are needed for reinitialization itself. 3:simple-p* 1Operation on 2si:process** Returns 2nil* for a normal process, 2t* for a simple process. See 4(PROCESSES-1)Process Flavors*. 3:idle-time* 1Operation on 2si:process** Returns the time in seconds since this process last ran, or 2nil* if it has never run. 3:total-run-time* 1Operation on 2si:process** Returns the amount of time this process has run, in 60ths of a second. This includes cpu time and disk wait time. 3:disk-wait-time* 1Operation on 2si:process** Returns the amount of time this process has spent waiting for disk I/O, in 60ths of a second. 3:cpu-time* 1Operation on 2si:process** Returns the amount of time this process has spent actually executing instructions, in 60ths of a second. 3:percent-utilization* 1Operation on 2si:process** Returns the fraction of the machine's time this process has been using recently, as a percentage (a number between 0 and 100.0). The value is a weighted average giving more weight to more recent history. 3:reset-meters* 1Operation on 2si:process** Resets the run-time counters of the process to zero. =Node: 4Run and Arrest Reasons* =Text: 3RUN AND ARREST REASONS :run-reasons* 1Operation on 2si:process** Returns the list of run reasons, which are the reasons why this process should be active (allowed to run). 3:run-reason* 1object* 1Operation on 2si:process** Adds 1object* to the process's run reasons. This can activate the process. 3:revoke-run-reason* 1object* 1Operation on 2si:process** Removes 1object* from the process's run reasons. This can stop the process. 3:arrest-reasons* 1Operation on 2si:process** Returns the list of arrest reasons, which are the reasons why this process should be inactive (forbidden to run). 3:arrest-reason* 1object* 1Operation on 2si:process** Adds 1object* to the process's arrest reasons. This can stop the process. 3:revoke-arrest-reason* 1object* 1Operation on 2si:process** Removes 1object* from the process's arrest reasons. This can activate the process. 3:active-p* 1Operation on 2si:process** 3:runnable-p* 1Operation on 2si:process** These two operations are the same. 2t* is returned if the process is active, i.e. it can run if its wait-function allows. 2nil* is returned if the process is stopped. =Node: 4Bashing the Process* =Text: 3BASHING THE PROCESS :preset* 1function* &rest 1args* 1Operation on 2si:process** Sets the process's initial function to 1function* and initial arguments to 1args*. The process is then reset so that any computation occuring in it is terminated and it begins anew by applying 1function* to 1args*. A 2:preset* operation on a stopped process returns immediately, but does not activate the process; hence the process will not really apply 1function* to 1args* until it is activated later. 3:reset* &optional 1no-unwind* 1kill* 1Operation on 2si:process** Forces the process to throw out of its present computation and apply its initial function to its initial arguments, when it next runs. The throwing out is skipped if the process has no present computation (e.g. it was just created), or if the 1no-unwind* option so specifies. The possible values for 1no-unwind* are: 2:unless-current* 2nil*Unwind unless the stack group to be unwound is the one currently executing, or belongs to the current process. 2:always* Unwind in all cases. This may cause the operation to throw through its caller instead of returning. 2t* Never unwind. If 1kill* is 2t*, the process is to be killed after unwinding it. This is for internal use by the 2:kill* operation only. A 2:reset* operation on a stopped process returns immediately, but does not activate the process; hence the process will not really get reset until it is activated later. 3:flush* 1Operation on 2si:process** Forces the process to wait forever. A process may not 2:flush* itself. Flushing a process is different from stopping it, in that it is still active and hence if it is reset or preset it will start running again. A flushed process can be recognized because its wait-function is 2si:flushed-process*. If a process belonging to a window is flushed, exposing or selecting the window resets the process. 3:kill* 1Operation on 2si:process** Gets rid of the process. It is reset, stopped, and removed from 2sys:all-processes*. 3:interrupt* 1function* &rest 1args* 1Operation on 2si:process** Forces the process to 2apply* 1function* to 1args*. When 1function* returns, the process continues the interrupted computation. If the process is waiting, it wakes up, calls 1function*, then waits again when 1function* returns. If the process is stopped it does not 2apply* 1function* to 1args* immediately, but will later when it is activated. Normally the 2:interrupt* operation returns immediately, but if the process's stack group is in an unusual internal state 2:interrupt* may have to wait for it to get out of that state. =Node: 4Process Flavors* =Text: 3PROCESS FLAVORS* These are the flavors of process provided by the system. It is possible for users to define additional flavors of their own. 3si:process* 1Flavor* This is the standard default kind of process. 3si:simple-process* 1Flavor* A simple process is not a process in the conventional sense. It has no stack group of its own; instead of having a stack group that gets resumed when it is time for the process to run, it has a function that gets called when it is time for the process to run. When the wait-function of a simple process becomes true, and the scheduler notices it, the simple process's function is called in the scheduler's own stack group. Since a simple process does not have any stack group of its own, it can't save control state in between calls; any state that it saves must be saved in data structure. The only advantage of simple processes over normal processes is that they use up less system overhead, since they can be scheduled without the cost of resuming stack-groups. They are intended as a special, efficient mechanism for certain purposes. For example, packets received from the Chaosnet are examined and distributed to the proper receiver by a simple process that wakes up whenever there are any packets in the input buffer. However, they are harder to use, because you can't save state information across scheduling. That is, when the simple process is ready to wait again, it must return; it can't call 2process-wait* and continue to do something else later. In fact, it is an error to call 2process-wait* from inside a simple process. Another drawback to simple processes is that if the function signals an error, the scheduler itself is broken and multiprocessing stops; this situation can be repaired only by aborting, which blasts the process. Also, when a simple process is run, no other process is scheduled until it chooses to return; so simple processes should never run for a long time without returning. Asking for the stack group of a simple process does not signal an error, but returns the process's function instead. Since a simple process cannot call 2process-wait*, it needs some other way to specify its wait-function. To set the wait-function of a simple process, use 2si:set-process-wait* (see below). So, when a simple process wants to wait for a condition, it should call 2si:set-process-wait* to specify the condition, then return. 3si:set-process-wait* 1simple-process* 1wait-function* 1wait-argument-list* Sets the 1wait-function* and 1wait-argument-list* of 1simple-process*. See the description of the 2si:simple-process* flavor (above) for more information. =Node: 4Other Process Functions* =Text: 3OTHER PROCESS FUNCTIONS process-enable* 1process* Activates 1process* by revoking all its run and arrest reasons, then giving it a run reason of 2:enable*. 3process-reset-and-enable* 1process* Resets 1process*, then enables it. 3process-disable* 1process* Stops 1process* by revoking all its run reasons. Also revokes all its arrest reasons. The remaining functions in this section are obsolete, since they simply duplicate what can be done by sending a message. They are documented here because their names are in the 2global* package. 3process-preset* 1process* 1function* &rest 1args* Sends a 2:preset* message. 3process-reset* 1process* Sends a 2:reset* message. 3process-name* 1process* Gets the name of a process, like the 2:name* operation. 3process-stack-group* 1process* Gets the current stack group of a process, like the 2:stack-group* operation. 3process-initial-stack-group* 1process* Gets the initial stack group of a process, like the 2:initial-stack-group* operation. 3process-initial-form* 1process* Gets the initial form of a process, like the 2:initial-form* operation. 3process-wait-function* 1process* Gets the current wait-function of a process, like the 2:wait-function* operation. 3process-wait-argument-list* 1p* Gets the arguments to the current wait-function of a process, like the 2:wait-argument-list* operation. 3process-whostate* 1p* Gets the current who-line state string of a process, like the 2:whostate* operation.