Task State section and control gate of the Assembly

Source: Internet
Author: User

Each task has a task status section TSS, which is used to save information about the task and to transform the privilege level and task transitions within the task. In order to control the transfer of the privilege level transformation in the task, the control gate is usually used to control the task switching. This article describes the task Status section and the control door.

< a > System Segment descriptor

A system segment is a special segment that is used to implement a storage management mechanism. In 80386, there are two system segments: The task State segment TSS and the local descriptor LDT segment. The descriptor used to describe the system segment is called the System segment descriptor.

1. Format of System segment descriptor

The general format of the system segment descriptor is shown in the following table.

System segment
Descriptor
M+7 M+6 M+5 M+4 M+3 M+2 M+1 M+0
Base (31...24) Attributes Segment Base (23...0) Segment limite (15...0)

System segment
Descriptor
The properties
Byte m+6 Byte m+5
bit6 bit5 bit3 bit2 bit0 bit7 bit5 BIT4 bit2 bit1 bit0
G X 0 Avl Limit (19...16) P Dpl DT0 TYPE

They are similar to the storage segment descriptor, and the distinguishing flag is the value of the descriptor type bit dt in the attribute byte. Dt=1 represents a storage segment, dt=0 represents a system segment. The Janki address and Segment boundary fields in the system segment descriptor are exactly the same as the storage segment descriptor, and the function of the G-bit, AVL-bit, p-bit, and DPL fields in the attribute is exactly the same. The D-bit in the storage Segment Descriptor property is not used in the system segment descriptor and is represented by symbol X. The Type field of the system segment descriptor is still 4 bits, and the encoding and presentation of the type is listed in the following table, and the meaning is completely different from the type of the storage segment descriptor.

System segment
Type
Type encoding Description
0 Not defined
1 Available 286TSS
2 LDT
3 Busy 286TSS
4 286 Call Door
5 Task Door
6 286 Interrupt Door
7 286 Trap Door
System segment
Type
Type encoding Description
8 Not defined
9 Available 386TSS
A Not defined
B Busy 386TSS
C 386 Call Door
D Not defined
E 386 Interrupt Door
F 386 Trap Door

As can be seen from the table above, only descriptors with type 2, 1, 3, 9, and B are true system segment descriptors that describe system segment Ldt and task state segments TSS, and other types of descriptors are gate descriptors. Using the storage Segment descriptor structure type defined previously, desc can still easily describe the system segment descriptor in the program. It is important to note that the selection of the system segment descriptor cannot be used to read and write the system segment, and the alias technology must be used to read and write the system segment.

2.LDT Segment Descriptor

The LDT segment descriptor describes the local descriptive chart segment of the task. For example: The following descriptor ldtable describes a local descriptor chart segment, the base address is 654321H, the byte-per-line boundary is 1FH, and the descriptor privilege level is 0.

    Ldtable  DESC  <1FH,4321H,65H,82H,,>

The LDT segment descriptor must be scheduled to be valid in the Global Descriptor table. When loading a LDTR register, information such as the LDT Janki address and segment bounds in the descriptor is loaded into the LDT segment descriptor cache register.

3. Task Status Segment Descriptor

The Task Status section TSS is used to save various state information for a task. The task status segment descriptor describes a task status section The TSS descriptor is divided into 286TSS and 386TSS categories. The TSS descriptor provides information such as the base address of the task status segment and the size of the task State segment. For example, the following descriptor Temptask describes an available 386 task status segment, the base address is 123456H, the limit in bytes is 104, and the descriptor privilege level is 0.

    Temptask  DESC  <104,3456H,12H,89H,,>

When loading the task state Segment Register TR, information such as the Janki address and segment bounds in the descriptor is loaded into the TR cache register. Load a TR register when a task switches or executes a ltr instruction.

The type in the TSS descriptor stipulates that TSS is either "Busy" or "available". If a task is a task that is currently being performed, or is linked to a task on the current task with a link field in TSS, the task is a busy task, otherwise the task is a "available" task.

The task switching can be realized directly through the TSS descriptor or through the task gate by using the transfer instruction JMP and the call between paragraphs.

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.