Linux Fundamentals: Process Management

Source: Internet
Author: User

1. Processes and programs (process and program)

First we make a clear definition of the process: the so-called process is an execution environment that consists of the body segment (text), the user data segment (users segment), and the system data segment (systems segment).

A program is just an ordinary file, a collection of machine code instructions and data stored in an executable image (executable image) on disk, so the program is a static entity. Linux is a multitasking operating system, that is, multiple programs can be loaded into memory and run, the operating system for each program to establish a running environment is the creation process, each process has its own virtual address space, they do not interfere with each other, even if you want to interact (for example, multiple processes work together to complete a job), Also through the inter-process communication mechanism (IPC) provided by the kernel. The Linux kernel supports the concurrent execution of multiple processes in a virtual manner, which is achieved by constantly saving and switching the running environment of the program, and choosing which process to run is determined by the scheduler.

A process is a dynamic entity, and the process entity consists of three separate parts:

(1) Body segment (text): Stores the machine instructions executed. This segment is read-only (so you cannot write code that you can modify here), which allows the code to be shared between two or more processes that are running in the system. For example, several users are using a text editor, and only one copy of the program instruction is needed in memory, and they all share this copy.

(2) User Data segment: All data that the process segment directly during execution, including all variables used by the process. Obviously, the information contained here can be changed. Although a body segment can be shared between processes, each process needs its own private user data segment. For example, a user who edits text at the same time, while running the same program __ editor, each user has different data: the text being edited.

(3) System segment: This section effectively stores the environment in which the program runs. In fact, this is precisely the difference between procedures and processes. As mentioned earlier, a program is a static thing composed of a set of instructions and data, which is the body segment and user data segment that the process originally used. As a dynamic thing, a process is a cross-complex of information about a body segment, a user data segment, and a system data segment, where the system data segment is the most important part of the process entity, and it is said that it effectively stores the environment in which the program is running because this part holds the control information of the process. There are many processes in the system in which the operating system manages them and schedules them to run through these control messages. Linux establishes TASK_STRUCT data structures for each process to accommodate these control information.


Processes and programs (process and program)

, the relationship between procedure and process

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/73/C9/wKiom1YHb36gJkBxAAAuvejlWw8504.gif "title=" Image002.gif "alt=" Wkiom1yhb36gjkbxaaauvejlww8504.gif "/>

2. Work Management (Job control)

Job management is when we log into the system to get the bash shell, and at the same time under a single terminal to conduct multiple work behavior management. Bash can only manage its own work and cannot manage other bash's work, in addition, the work is divided into the foreground and the day after tomorrow, the day after tomorrow is divided into "pause" and "run".

2.1&: Can drop commands directly into the background execution

For example, we will back up the/etc directory into/tmp/etc.tar.gz and drop it into the background.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/73/C7/wKioL1YHcy-h_s7WAAAyyCIlISk804.jpg "style=" float: none; "title=" 00.png "alt=" Wkiol1yhcy-h_s7waaayycilisk804.jpg "/>

2.2 "&" is dropped to the background, [1] represents the work number, "2448" represents the PID

CTRL + Z: You can drop the current work to the background pause, as I edit/etc/fstab after pressing CTRL + Z, as shown below

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/73/C9/wKiom1YHcyjS0IkXAABJxoXrUI0669.jpg "style=" float: none; "title=" 01.png "alt=" Wkiom1yhcyjs0ikxaabjxoxrui0669.jpg "/>

[2] Represents a second job, done means complete, stopped means stop

2.3 View the status of the current background:

[[email protected] ~]# jobs

    • -l lists job number and command, PID

    • -R lists only the jobs that are running

    • -s lists only jobs with a stopped state

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/73/C9/wKiom1YHdSGBYPSOAAAg0jdVC5U153.jpg "title=" 02.png "alt=" Wkiom1yhdsgbypsoaaag0jdvc5u153.jpg "/>

2.4 Get background work to foreground processing: FG

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/73/C7/wKioL1YHddPiNJnqAAA7A4v_1cU301.jpg "title=" 03.png "alt=" Wkiol1yhddpinjnqaaa7a4v_1cu301.jpg "/>

%2 is to take out number 2nd, where "+" stands for the default fetch work, "-" to take the job. If FG has no parameters, the "+" work is used by default.

2.5 Let work become operational in the acquired state: BG

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/73/C9/wKiom1YHdzjBW1f5AADTnFypPok017.jpg "title=" 04.png "alt=" Wkiom1yhdzjbw1f5aadtnfyppok017.jpg "/>

You can see that the BG command allows the work to be changed from stopped to running.

2.6 Managing Background work: Kill

[[email protected] ~]# Kill

    • -l list current kill can use the signal

    • 1 re-read the configuration file of the parameter once

    • -9 force removal of a job immediately

    • -15 end a job with a normal process

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/73/C9/wKiom1YHeTnC5MrOAABWrrUlms4599.jpg "title=" 05.png "alt=" Wkiom1yhetnc5mroaabwrrulms4599.jpg "/>

Kill-l command to view all single

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/73/C9/wKiom1YHeczCE7rFAAGksctCNBk169.jpg "title=" 07.png "alt=" Wkiom1yheczce7rfaagksctcnbk169.jpg "/>


3. Process Management




















This article is from the "Genius from Repetition" blog, please be sure to keep this source http://laoli110.blog.51cto.com/9136611/1698562

Linux Fundamentals: 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.