Linux Process Learning (1)

Source: Internet
Author: User

Process Concept

 

A process is a running activity that can be executed concurrently by a program with independent functions about a data set. It is a computer program in the active state. As the basic cell of the system, a process is not only an entity that runs independently inside the system, but also a basic entity for independent competition of resources.

Bytes -------------------------------------------------------------------------------------------------

Process attributes

Process Definition: A process is an execution process of a program; a program is static, and it is a set of executable code and data stored on a disk; A process is a dynamic concept. It is the basic scheduling unit of the Linux system. A process consists of the following elements:

 

Context in which the program reads and executes the program.

The directory currently executed by the program.

Files and directories of program services.

The access permission of the program.

Memory and other system resources allocated to the process.

 

The most well-known attribute in a Linux Process is its process number (ProCess idenity number, pid) and its parent process ID (parent process ID, ppid ).

PID and ppid are both non-zero positive integers. A pid uniquely identifies a process.

A process creates a new process called a child process ). On the contrary, the process that creates a child process is called the parent process.

All processes trace their ancestors and eventually fall into the process with process Number 1. This process is called the INIT process, which is the first process started after kernel self-lifting.

Pstree command

Linux provides a pstree command that allows you to view the inheritance relationships between running processes in the system. Enter pstree directly in the command line. The program will list the inheritance relationships between processes running in the system in a tree structure.

-----------------------------------------------------------------------------

Process Structure

A process in Linux has three parts of data in the memory: "data segment", "Stack segment", and "code segment ".

Code segments store the data of program code. If several processes on the machine run the same program, they can use the same code segment.

The data segment stores the global variables, constants, and dynamic data space of the program.

The stack segment stores the return address of the subroutine, the parameters of the subroutine, and the local variables of the program. The stack segment is included in the process control block.PCB(Process Control Block. The PCB is at the bottom of the Process core stack and no additional space is allocated.

-----------------------------------------------------------------------------

Process status

User status: the status of a process running in the user status.

Kernel Status: the status of the process running in the kernel status.

In-memory ready: the process is not executed, but is in the ready state. It can be executed as long as the kernel schedules it.

Sleep in memory: the process is sleeping and the processStorageIn the memory, it is not switched to SWAPDevice.

Ready and swapped out: the process is in the ready state, but it must be swapped into the memory before the kernel can schedule it to run again.

Sleep and swap out: the process is sleeping and the memory is swapped out.

Preemptive: when a process returns from the Kernel Status to the user status, the Kernel performs context switching and schedules another process. The previous process was in the preemptive status.

Creation status: the process has just been created. This process exists, but it is neither ready nor sleep. This state is the initial State of all processes except process 0.

Dead state (zombIE): The process stops calling exit. The process does not exist any more, but there are still records in the progress table. This record can be collected by the parent process.

 

 

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.