Programming <6> --- Task Switching

zhaozj2021-02-16  49

Task switching

In this section, I will explain how to achieve the conversion between tasks. The following code has three tasks, which are temporary tasks, task A, task B. The transition between tasks requires the task door Attaskgate, the task door is one of the door, and the selection of the task door must be a task status segment TSS descriptor in GDT. The entrance of the task is saved in TSS. Using Inter-Division Transfer instructions JMP and segment call command Call, the task door can achieve task switching.

For example, the entrance to Tsus Tob Descriptor <0, TSSB_SEL, 0, Attaskgat DPL2, 0> task is a descriptor TSSB_SEL of the task status section TSSBSEG.

Each task has its own task segment TSS, when the task is converted. The current task's register value and other related information are saved in their corresponding task segment, and then read data from the task segment of the task to be run, used to initialize the register. So you will see two statements of MOV AX, TSS0_SEL, LTR AX in the code. These two instructions are saved to TSS0SEG in TSS0SEG, and 0 this command implements task switching. When the computer runs this instruction, the computer reads the data from the task segment TSSaseg, and then places the corresponding registers. This achieves the switching from the temporary task to task A.

When the instruction runs to the Jump Tob_SEL, 0, the selection sub-TSSB_SEL in the task door indicates the TSS of the task B, and the TSS of the task B at this time is available, so the task switch can be successfully switched smoothly. The field of task A is saved to the TSS segment of Task A, and the field saving of the task B is restored from the TSS recovery of the task B.

The last task B returns to the temporary task by calling the door ToreAlm, then switching to the real mode.

For specific code, please see http://ywchen2000.51.net/new.htm

Finally, I would like to thank the CSDSJKK () point of 9CBS assembly sector.

Reference: Yang Jiwen edited << 80x86 assembly language programming textbook >>

转载请注明原文地址:https://www.9cbs.com/read-26963.html

New Post(0)