Task Switch Details

Figure 11-3 on page 199 through Figure 11-5 on page 201 illustrate the steps taken by the processor to perform a switch from task to another.

Figure 11-3. Task Switch Flowchart (1-of-3)


Figure 11-5. Task Switch Flowchart (3-of-3)


Switch Due To an Interrupt or Exception

A task switch results when a hardware interrupt or a software exception selects an entry in the IDT (Interrupt Descriptor Table, pictured in Figure 11-2 on page 196) that contains a valid Task Gate. A privilege check is not performed.

Switch as a Result of a Far Call

A far CALL instruction causes a task switch under the following circumstances (and the offset portion of the branch target address is irrelevant and is discarded):

  • When it selects a TSS descriptor in the GDT. In this case, the lesser privileged of the selector RPL and the currently executing program's CPL must meet or exceed the privilege level indicated by the TSS descriptor's DPL. This is typically zero, severely restricting the programs that are successful in selecting the TSS descriptor.

  • When it selects a Task Gate descriptor in either the GDT or LDT. In this case, the lesser privileged of the selector RPL and the currently executing program's CPL must meet or exceed the privilege level of the Task Gate descriptor's DPL (which can be different than the DPL of the TSS descriptor it points to in the GDT).

The difference between the two is in how the privilege check is performed. The sections that follow assume that the privilege check has been passed.

Switch as the Result of a Far Jump

A far jump instruction causes a task switch under the following circumstances (and the offset portion of the branch target address is irrelevant and is discarded):

  • When it selects a TSS descriptor in the GDT. In this case, the lesser privileged of the selector RPL and the currently executing program's CPL must meet or exceed the privilege level indicated by the TSS descriptor's DPL. This is typically zero, severely restricting the programs that are successful in selecting the TSS descriptor.

  • When it selects a Task Gate descriptor in either the GDT or LDT. In this case, the lesser privileged of the selector RPL and the currently executing program's CPL must meet or exceed the privilege level of the Task Gate descriptor's DPL (which can be different than the DPL of the TSS descriptor it points to in the GDT).

The difference between the two is in how the privilege check is performed. The sections that follow assume that the privilege check has been passed.

Switch Due to a BOUND/INT/INTO/INT3 Instruction

A task switch occurs if any of the following instructions select a Task Gate in the IDT:

  • The BOUND instruction generates a Bound Range Exceeded exception if the supplied array index is not within the bounds of the indicated memory array. This selects entry five in the IDT. If this entry contains a Task Gate descriptor, a task switch occurs. No privilege check is performed.

  • The INT nn instruction selects entry nn in the IDT. If entry nn contains a Task Gate descriptor and the CPL of the currently executing program meets or beats the DPL of the Task Gate descriptor, a task switch occurs.

  • When the INTO (Interrupt On Overflow) instruction detects that EFlags[OF] = 1, it indexes to entry four in the IDT. If this entry contains a Task Gate descriptor, a task switch occurs. No privilege check is performed.

If the BOUND instruction selected a Task Gate, the resultant task switch and return is handled in the same manner as an exception (because it is one). The actions taken are detailed in the section entitled “Task Switch Details” on page 196.

If the instruction is INT nn or INTO, the resultant task switch and return is handled in the same manner as a far CALL. The actions taken are detailed in the section entitled “Switch as a Result of a Far Call” on page 197.

Switch Due to Execution of an IRET

A task may called due to any of the following:

  • Interrupt.

  • Exception.

  • Execution of the INTO, INT3, or BOUND instruction.

  • Execution of a CALL instruction.

In all of these cases, the last instruction executed in the called task is the IRET instruction. When IRET is executed with EFlags[NT] = 1, this causes the processor to switch back to the calling task.

Figure 11-4. Task Switch Flowchart (2-of-3)


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.128.226.121