Starting from linux: Process Overview-process switching
Source: Internet
Author: User
Linux principle: Process Overview-process switching-general Linux technology-Linux programming and kernel information. For details, see the following. Today I am still studying the general concept of the process and have learned something about Task Switching. The following is a summary:
1. tast_struct Structure
It is a data structure. It can be said that it represents a process. It has many fields, generally including:
ID: process ID, user ID, and group ID.
Status: four basic statuses of Linux Processes
Scheduling information: priority, time slice, etc.
Process Chain information: pointer of parent process and child process
File Information: open a file or Virtual File System
Context information: the running environment of the process
Ii. task management and scheduling in I386 System
The I386 system supports switching between tasks on the hardware. For this purpose, a new segment is added: the task status segment (TSS). It is also a segment like a data segment and a code segment, and it records the status information of the task.
Like other segments, it also describes its structure: TSS Descriptor Table, which records a TSS information and a TR register that points to the TSS of the current task. During task switching, the cpu writes the content of the original register to the corresponding TSS, and fills in the content of the new TSS to the register. This enables task switching.
Iii. Linux Process Switching
Linux task switching is implemented through the macro switch_to, which uses the long-hop command. When the operand of the long-hop command is the TSS descriptor, it will cause the switch of the CPU task, the cpu saves the status of all registers to the TSS segment pointed to by the current task register TR (the task status segment of the current task), and then uses the operand of the long-hop instruction (TSS descriptor) locate the TSS segment of the new task, enter the content in each register, and then update the TSS selector of the new task to TR. In this way, the system will officially start running the new switchover task. The tss member in task_struct mentioned above records the content of the TSS segment.
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