Linux Process Management

Source: Internet
Author: User
Tags semaphore

Process Management

I. Basic knowledge

1. The memory space is divided into: linear space and physical space
Linear space: Memory is divided into page boxes, fixed storage space
Virtual memory instruction, data, heap area, stack area
The designation and data of the resident memory system

2. Process Context Switch: Process switching, saving the field of the process that will be exited, loading the next process to run
Properties of the process:
Process number
Memory space
Start user
Parent process
Consume CPU Time
3. Because of a thread, a process can work on multiple CPUs, concurrently executing

4. Process status
Running state
Uninterrutible Sleep non-disruptive: requires an I/O resource interrupt,
Interrutible sleep interrupted: not due to I/O interrupts

Zombie Process: The process is over, the occupied memory space is not released

5. The process is a parent-child relationship
All processes are child processes of Init

6. The process has a priority of 0-139 digits the lower the priority level
0-99: Kernel-tuned
100-139: User-controllable

  Process lookup time large o Standard
O (1)
O (n)
O (logn)
O (n^2)
O (2^ x)
process with high priority
1). Get more CPU Uptime
2) More priority for running opportunities Nice value: the smaller the elegant friendly -20--19:nice value, the higher the priority

100-139: The corresponding process priority number
The value of nice for the default process is 0
Ordinary users can only adjust their own process of nice
Administrators are free to adjust

7.PID: Process Number
Each digital directory under/proc corresponds to a process, kernel-mapped file, pseudo file system
Init's process number is always 1

Two. Process commands
1.ps Process State

BSD Style:

A: Show all processes associated with the terminal
U: Show User's startup
x: Show all processes unrelated to the terminal
Classification of processes:
Terminal-related processes
Terminal-independent processes
Process Status:
D: Non-disruptive sleep
R: Run or ready
S: interruptible Sleep
T: Stop
Z: Zombie

<: high-priority process
N: Low-priority process
+: Process of the foreground process group
L: Multithreaded Process
S: Session process first Process
VSZ: Virtual Memory Set
RSS: Resident Memory Set

COMMAND [] Identifies the kernel process

SYS-style
Ps-ef
Ps-ef
Ps-elf

Ps-o Pid,comm,ni Show foreground process only
Ps-axo Pid,comm,ni Show All Processes
2.pstree Show Process Tree

3.pgrep view process with grep, show only process number
Pgrep-u Root

4.PIDOF View PID of a specified process
PIDOF Init

5.top: Monitor each process, refresh every 5 seconds

01:06:48 Current time
Up 1:22 System run time, format last: minutes
1 user Number of currently logged on users
Load average:0.06, 0.60, 0.48 System load, which is the average length of the task queue.
The three values were 1 minutes, 5 minutes, and 15 minutes ago to the present average.

The second to third behavior process and CPU information. When there are multiple CPUs, the content may be more than two lines. The contents are as follows:

tasks:29 Total Total number of processes
1 Running Number of processes that are running
Sleeping Number of processes for sleep
0 stopped Number of processes stopped
0 Zombie Number of zombie processes
Cpu (s): 0.3% US Percentage of CPU occupied by user space
1.0% Sy Percentage of CPU consumed by kernel space
0.0% ni CPU percentage of processes that have changed priority in user process space
98.7% ID Percentage of idle CPU
0.0% WA Percentage of CPU time waiting for input and output
0.0% hi
0.0% si

The last two behavior memory information. The contents are as follows:

mem:191272k total< /td> Total physical memory
173656k used Total amount of physical memory used
17616k free Total idle memory
22052k buffers

swap:192772k total

Swap area totals
0k used Total number of swap areas used
192772k free Total idle swap area
123988k cached buffer the total number of swap areas.
The contents of the memory are swapped out to the swap area and then swapped in to memory, but the used swap area has not been overwritten, and
The value is the size of the swap area where the content already exists in memory .
The corresponding memory is swapped out again without having to write to the swap area again.


Options that can be interactively entered at display time
M: Sort based on the size of the resident memory
P: Sort by CPU percent usage
T: Sort by cumulative time

L: Show average load and start time
T: whether to display process and CPU status related information
M: whether memory-related information is displayed

C: Whether to display full command line information
Q: Exit Top
K: Terminate a process

Top
-D: Specify the delay length in seconds
-B: Batch mode
-N #: Total number of batches displayed in batch mode

6. Inter-process communication (IPC)
Shared memory
Signal: Signal
Semaphore: Semaphore

Kill-l All available signals
Important signal.
1) SIGHUP allows a process to reread the configuration file and let the configuration information take effect without rebooting
2) SIGINT Interrupt a process
9) SIGKILL kills a process and forcibly kills
SIGTERM terminate the default signal for a process kill

Specify a signal
Signal Number: KILL-1
Signal Name: Kill-sigkill
Signal name shorthand: Kill-kill

Kill process number kills process
Killall COMMAND

7. Adjust Nice
Adjust the nice values that have been started
Renice New Nice PID

Specify nice at startup
Nice-n NI COMMAND
Nice-n-3 Useradd hbase

8. Foreground job: Occupy command prompt
Background job: After startup, release the command prompt, and subsequent operations are completed in the background
TAR-JCF file File & go to Background run

Front desk to backstage: Ctrl + Z is at the front desk work sent backstage
or command +&.
BG: Let the backstage stop the employment run
BG [[%] job number]
Jobs: View all jobs in the background
Job number is different from process number
+: Command will default operation for jobs
-: command to perform a second job

FG: Returning background jobs to the foreground
FG [[%] job number]
Kill% job number termination job

10.vmstat: System Status View command
1 Refresh every 1 seconds
1 5 shows once every 1 seconds but only 5 times
11.uptime
/proc/memifo Memory Information
CD/PROC/1 Cat Maps view memory consumed by process files

Linux Process Management

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.