"Notes finishing" Unix/linux process management (i)

Source: Internet
Author: User

Process management under the Unix/linux


1. Processes and Procedures
~~~~~~~~~~~~~


1) The process is the running program. A running program,
There may be multiple processes. The process performs a specific task in the operating system.


2) The program is stored on the disk,
A static entity that contains executable machine instructions and data.
A process or task is a computer program that is active.


2. Classification of processes
~~~~~~~~~~~~~


1) The process is generally divided into three categories: interactive process, batch process and daemon process.


2) daemons are always active, usually running in the background.
Daemons are typically activated automatically by the system at boot time by a script,
Or it can be started by Superuser root.


3. View the process
~~~~~~~~~~~


1) Simple Form


# PS


Displays the process information for the current user with control terminal in a shorthand manner.


2) BSD style common options


# Ps-axu


A-all users have the process of controlling the terminal
X-includes a process with no control terminal
U-Display in an exhaustive manner
W-Display in a larger column width


3) SVR4 style common options


# PS-EFL


-E or-A-process for all users
-A-process of the current terminal
-u user name or user ID-process for a specific user
-G group name or group ID-process for a specific group
-F-Display in full format
-F-Display in more complete format
-L-Display by long format


4) Process Information list


User/uid: The user ID of the process.


PID: Process ID.


%CPU/C: CPU usage.


%MEM: Memory utilization.


VSZ: Takes up virtual memory size (KB).


RSS: The physical memory size in kilobytes (KB).


TTY: Terminal device number, "?" Represents a non-control terminal, such as a background process.


STAT/S: Process state. The following values are desirable:


O-ready. Waiting to be dispatched.
R-run. There is no O status under Linux, and the ready state is also indicated by R.
S-wakes up to sleep. The system interrupts, gets the resources, receives the signal,
Can be woken up and transferred to a running state.
D-No waking sleep. Can only be awakened by the WAKE_UP system call.
T-Pause. Received the sigstop signal into the suspended state,
Receive the Sigcont signal into the running state.
W-Waits for memory paging (the 2.6 kernel is discarded later).
X-Death. Not visible.
Z-Zombies. has stopped running, but its parent process has not yet acquired its state.
<-high priority.
N-Low priority.
L-There is a paging that is locked into memory. Real-time process and custom IO.
S-session first process.
L-Multithreading process.
+-in the foreground process group.


Start/stime: Process start time.


Time: Process runtime.


Command/cmd: Process directives.


F: Process flag. Can be taken from the following values:


1-generated by fork but no exec.
4-Super User privileges.


PPID: Parent Process ID.


NI: Process Nice value, 20 to 19, can be modified by system call or command.


PRI: Process priority.


Static priority = Nice,60 to 99, the smaller the value the higher the priority.
The kernel is based on the static priority,
The actual (dynamic) priority is calculated based on the interaction of the process.
To reflect the rewards of IO-consuming processes,
and penalties for processor-consuming processes.


ADDR: The memory address of the kernel process. The normal process displays "-".


SZ: The number of virtual memory pages occupied.


Wchan: The kernel function or event that the process is waiting for.


PSR: Which processor the process is currently assigned to run.


4. Parent process, child process, orphan process, and zombie process
-------------------------------------


Kernel processes (0)
Init (1)
xinetd
in.telnetd <-User Login
Login
Bash
Vi


1) After the parent process starts the child process,
The child process runs concurrently with its parent process under the dispatch of the operating system.


2) The child process ends before the parent process,
The child process sends a SIGCHLD (17) signal to the parent process,
The parent process reclaims related resources for the child process.


3) The parent process ends before the child process, and the child process becomes the orphan process,
Being adopted by the INIT process at the same time, it becomes the child process of the INIT process.


4) The child process ends before the parent process,
But the parent process does not reclaim the associated resources for the child process.
The child process becomes a zombie process.


5. Process identifier (process ID)
~~~~~~~~~~~~~~~~~~~~~

PID-process number, which is the unique identity of the process in the operating system, the process number is allocated in a deferred reuse strategy, and at every moment the process number is guaranteed to be unique.

Second, Getxxxid
------------


Getpid -Get Process ID
Getppid -Get Parent Process ID
Getuid -Get the actual user ID
Geteuid -Get a valid user ID
Getgid -Get the actual group ID
Getegid -Get valid Group ID


"Notes finishing" Unix/linux process management (i)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.