Chapter 5th Process Environment (1) _ Process structure (task_struct)

Source: Internet
Author: User

1. concept and process structure of the process

1.1 Process

(1) program: A collection of ordered instructions stored on disk, which is an executable file stored in a disk file . But without any notion of execution, it is static .

(2) Progress (process)

the execution instance of the ① program, known as a process , is a dynamic concept that is the process of program execution, including creation, scheduling, and extinction.

The ② process has separate permissions and responsibilities, and it does not affect the rest of the process if a process in the system crashes.

③ each process runs in its own virtual address space , and processes can communicate with each other through a mechanism controlled by the kernel.

(3) Process ID: Each linux process has a unique numeric identifier called the process ID, and the process ID is always a non-negative integer.

1.2 process structure in the kernel

(1) Task_struct structural body

① process Number (PID): Used to uniquely identify a process.

 the state of the ② process , which identifies whether the process is in a running state, a waiting state, a stop state, or a dead state

  A. Running state: The process is either running at this time, or ready to run

B. Wait state: At this point the process waits for an event to occur or some kind of system resource

C. Stop state: The process is terminated at this time

D. Death state: This is a terminated process, but it also occupies a task_struct structure in the process vector array.

③ the priority and time slices of the process.

Different priority processes are scheduled to run differently, typically high-priority processes run first. Time slices identify when a process will be run by the processor

④ Virtual Memory

Most processes have some virtual memory (kernel threads and daemons are not), and Linux must track how memory is mapped to system physical memory.

⑤ processor-related contexts

A process can be thought of as the sum of the current state of the system. Whenever a process runs, it uses the processor's register, stack, and so on, which is the context of the process. Also, whenever a process is paused, all CPU-related contexts must be stored in the task_struct of the process . When the process is restarted by the scheduler, its context resumes from here.

(3) Two data structures associated with a file

  ①fs_struct: It contains the current working directory and root directory of this process, umask. Umask is the default mode in which new files are created, which can be changed by a system call.

 ②files_struct: contains information about all the files that this process is using . The F_mode field describes what mode the file was created in: Read-only, read-write, or write-only. F_pos saves the location where the next read or write in the file will occur . F_inode describe the VFS index node of a file, whereas F_ops is a pointer to a routine vector, each representing a function that wants to be applied to the action of the file . The Linux process starts with 3 file descriptors opened , which are standard input devices, standard output devices, and standard error devices , and are typically inherited from the parent process that created the process. .

Chapter 5th Process Environment (1) _ Process structure (task_struct)

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.