Simple overview of process management in Linux

Source: Internet
Author: User
Tags semaphore

Simple overview of process management in Linux

Directory

Linux kernel feature Brief

Process-related concepts

Process Management Viewing Tools

A Linux kernel feature Brief

1. Process Management

The kernel is responsible for creating and destroying processes and handling their connections to the outside world (input and output). Communication between different processes (through signals, pipelines, or interprocess communication primitives) is fundamental to the overall system function and is handled by the kernel. In addition, the scheduler, which controls how the process shares the CPU, is part of the process management. More generally, the kernel's process management activity implements the abstraction of multiple processes over a single or several CPUs

2. Memory Management

The memory of a computer is the primary resource, and the strategy used to process it is critical to system performance. The kernel establishes a virtual address space on a limited number of available resources for each of these processes. The different parts of the kernel interact with the memory management subsystem through a set of function calls, from simple malloc/free to more complex functions.

3. File System
Linux is largely based on the concept of file systems; Almost anything in Linux can be viewed as a file. The kernel builds a structured file system on top of unstructured hardware, and the result is that the abstraction of a file is very much applied throughout the system. In addition, Linux supports multiple file system types, that is, different data organization methods on physical media.

4. Device Control

Almost every system operation is eventually mapped to a physical device. In addition to processors, memory, and very few other entities, any device control operation in all is done by code that is specific to the device being addressed. These codes are called device drivers. The kernel must be embedded in the driver for each peripheral that appears in the system, from the hard drive to the keyboard and tape drives.

5. Network

The network must be managed by the operating system because most of the network operations are not specific to a process, and the messages that enter the system are asynchronous events that must be collected, identified, and distributed before a process takes over. The system is responsible for the delivery of data packets between the program and the network interface, which must be executed according to the program's network activity. In addition, all routing and address resolution issues are implemented in the kernel.

Two Process-related concepts

1. Process

Process : A copy of a running program that is loaded into a collection of instructions in memory that has a life cycle, created by its parent process

Process ID: Used to mark individual processes

Task Struct:linux Kernel Store process information data structure format, is a fixed format

Task List: A list of task structs consisting of multiple tasks

2. Process Priority 0-139

0: Generally not used

1-99: real-time priority; The higher the number priority, the system automatically arranges

100-139: static priority; The smaller the number, the higher the priority, which can be changed manually

3.Nice value

20 to 19, corresponding to 100 to 139 or 99

Ordinary users can only lower their own priority, the root user is free to adjust

Two pairs per queue: Run queue, expiration queue, 140 to 280 team, CPU interrupt control to process run time

4. Process Memory

Page frame: Pages box, storing page data, saving pages 4k

Mmu:memory Management Unit is responsible for converting linear and physical addresses

The memory unit of the process may not be contiguous

Lru:least Recently used uses least recent algorithms to free up memory physical address space and linear address space

Assuming that the sequence is 4 3 4 2 3 1 4 2 the physical block has 3, then

1th Round 4 in memory 4

2nd Round 3 in memory 3 4

3rd Round 4 in Memory 4 3

4th Round 2 Transfer into memory 2 4 3

5th Round 3 Transfer into memory 3 2 4

6th Round 1 transfer into memory 1 3 2

7th Round 4 Transfer into memory 4 1 3

8th Round 2 transfer into memory 2 4 1

Ipc:inter Process Communication interprocess communication

On the same host: signal signal, shm:shared memory share, Semerphor semaphore gesture

On different hosts: rpc:remote procecure Call Remote procedure calls, socket sockets

5. Process Type

Daemon: daemon, process initiated during system boot, and terminal-independent process

Foreground process: terminal-related, process initiated through terminal

Note: You can also send the foreground-initiated process to the background to run in daemon mode.

6. Process Status

Operating state: Running, the process consumes CPU, and runs on the CPU;

Readiness: Ready, the process already has the operating conditions, but the CPU has not been allocated;

Interruptible sleep state: A process in this state is suspended because it waits for a certain event to occur (such as waiting for a socket connection, waiting for a semaphore). The TASK_STRUCT structure of these processes is placed in the waiting queue for the corresponding event. When these events occur (triggered by an external interrupt or triggered by another process), one or more processes in the corresponding wait queue will be awakened.

Non-disruptive sleep: The process is asleep, but the process is non-disruptive at the moment. Non-interruptible means that the CPU does not respond to interrupts from external hardware, but rather that the process does not respond to asynchronous signals. In most cases, the process should always be able to respond to an asynchronous signal when it is in a sleep state. But there's a delay.

Interruptible: interruptable

Non-interruptible: uninterruptable, non-interruptible, refers not to the CPU not responding to external hardware interrupts, but rather the process does not respond to asynchronous signals.

Stop state: Paused in memory, but not dispatched unless manually initiated; stopped

Zombie State: Zombie, end process, before the end of the parent process, the child process is not closed, not kill, that is, do not respond to the task signal, can not be killed with Sigkill

7. Process classification

Cpu-bound : CPU intensive, on CPU occupy large, non-interactive

Io-bound : io intensive, on io occupy large, interactive

Three Process Management viewing tool (PSTREE,PS,PGREP)

Information about each process in the Linux system is stored in each file in the/proc/pid directory

1.pstree: Process tree view

Pstree Common options:-p, print process PID

2.ps: View Current process status

PS-EF: Display all process information in full format (-e: Show All Processes,-F: Show process information in full format)

Description

UID: Start process user

PID: Run Process number

PPID: The process number of the parent process, 0 exists before the kernel starts init, the Init starts and terminates, there is a transition, typically swap process

Percent occupancy of c:cpu UTILIZATION,CPU

Stime: Start time

TTY: Related to its terminal

Time: Cumulative running CPU times

CMD: command to start this process

PS-EFH: Tree hierarchy Display (-H: Displays information about the process in a hierarchical (tree) structure)

F-ratio f displays more comprehensive information, hierarchical structure display, indentation same level

PSR: on which CPU to run, decimal number, 0/1/2/3

3.pgrep:

The pgrep command looks up the process from the running process queue by name and displays the process ID that was found. Each process ID is represented by a decimal number, separated by a split string and the next ID, and the default split string is a new line. For each property option, a user can specify a collection of possible values separated by commas on the command line.

Pgrep-u Root: Displays the ID of the process running as the root user (-u UID: Show only process PID running as specified user)


Simple overview of process management in Linux

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.