Terms related to processes are described in Table 62-1.
Table 62-1 Process Terminology
Term |
Description |
---|---|
Process |
An instance of program in execution. |
Lightweight process (LWP) |
Is a virtual CPU or execution resource. LWPs are scheduled by the kernel to use available CPU resources based on their scheduling class and priority. LWPs include a kernel thread, which contains information that has to be in memory all the time and an LWP, which contains information that is swappable. |
Application thread |
A series of instructions with a separate stack that can execute independently in a user's address space. They can be multiplexed on top of LWPs. |
A process can consist of multiple LWPs and multiple application threads. The kernel schedules a kernel-thread structure, which is the scheduling entity in the SunOS 5.x environment. Various process structures are described in Table 62-2.
Table 62-2 Process Structures
Structure |
Description |
---|---|
proc |
Contains information that pertains to the whole process and has to be in main memory all the time. |
kthread |
Contains information that pertains to one LWP and has to be in main memory all the time. |
user |
Contains the per process information that is swappable. |
klwp |
Contains the per LWP process information that is swappable. |
Figure 62-1 illustrates the relationship of these structures.
Most process resources are accessible to all the threads in the process. Almost all process virtual memory is shared. A change in shared data by one thread is available to the other threads in the process.
Table 62-3 describes commands for managing processes.
Table 62-3 Commands for Managing Processes
Use This Command ... |
To ... |
---|---|
ps |
Check the status of active processes on a system, as well as display detailed information about the processes |
dispadmin |
List default scheduling policies |
priocntl |
Assign processes to a priority class and manage process priorities |
nice |
Change the priority of a timesharing process |
See Chapter 63, Managing Processes (Tasks) for more information about commands for managing processes.
In addition, process tools are available in /usr/proc/bin that display highly detailed information about the processes listed in /proc, also known as the process file system (PROCFS). Images of active processes are stored here by their process ID number.
The process tools are similar to some options of the ps command, except that the output provided by the tools is more detailed. In general, the process tools:
Display more details about processes, such as fstat and fcntl information, working directories, and trees of parent and child processes
Provide control over processes, allowing users to stop or resume them
The new /usr/proc/bin utilities are summarized in Table 62-4.
Table 62-4 Process Tools
Tools That Control Processes |
What the Tools Do |
---|---|
/usr/proc/bin/pstop pid |
Stops the process |
/usr/proc/bin/prun pid |
Restarts the process |
/usr/proc/bin/ptime pid |
Times the process using microstate accounting |
/usr/proc/bin/pwait [-v] pid |
Waits for specified processes to terminate |
Tools That Display Process Details |
What the Tools Display |
/usr/proc/bin/pcred pid |
Credentials |
/usr/proc/bin/pfiles pid |
fstat and fcntl information for open files |
/usr/proc/bin/pflags pid |
/proc tracing flags, pending and held signals, and other status information for each lwp |
/usr/proc/bin/pldd pid |
Dynamic libraries linked into each process |
/usr/proc/bin/pmap pid |
Address space map |
/usr/proc/bin/psig pid |
Signal actions |
/usr/proc/bin/pstack pid |
Hex+symbolic stack trace for each lwp |
/usr/proc/bin/ptree pid |
Process trees containing specified pids |
/usr/proc/bin/pwdx pid |
Current working directory |
In these commands, pid is a process identification number. You can obtain this number by using the ps -ef command.
Chapter 63, Managing Processes (Tasks), describes how to use the process tool commands to perform selected system administration tasks, such as displaying details about processes, and starting and stopping them. A more detailed description of the process tools can be found in proc(1).
If a process becomes trapped in an endless loop, or if it takes too long to execute, you may want to stop (kill) the process. See Chapter 63, Managing Processes (Tasks), for more information about stopping processes using the kill command.
A process is allocated CPU time according to its scheduling class and its priority level. By default, the Solaris operating system has four process scheduling classes: real-time, system, timesharing and interactive.
Real-time processes have the highest priority. This class includes processes that must respond to external events as they happen. For example, a process that collects data from a sensing device may need to process the data and respond immediately. In most cases, a real-time process requires a dedicated system. No other processes can be serviced while a real-time process has control of the CPU. By default, the range of priorities is 100-159.
System processes have the middle priorities. This class is made up of those processes that are automatically run by the kernel, such as the swapper and the paging daemon. By default, the range of priorities is 60-99.
Timesharing processes have the lowest priority. This class includes the standard UNIX processes. Normally, all user processes are timesharing processes. They are subject to a scheduling policy that attempts to distribute processing time fairly, giving interactive applications quick response time and maintaining good throughput for computations. By default, the range of priorities is 0-59.
Interactive processes are introduced in the SunOS 5.4 environment. The priorities range from 0-59. All processes started under OpenWindows are placed in the interactive class and those processes with keyboard focus get higher priorities.
The scheduling priority determines the order in which processes will be run.
Real-time processes have fixed priorities. If a real-time process is ready to run, no system process or timesharing process can run.
System processes have fixed priorities that are established by the kernel when they are started. The processes in the system class are controlled by the kernel, and cannot be changed.
Timesharing and interactive processes are controlled by the scheduler, which dynamically assigns their priorities. You can manipulate the priorities of the processes within this class.