background image

Vol. 3A 7-9

TASK MANAGEMENT

A task can be accessed either through a task-gate descriptor or a TSS descriptor. Both of these structures satisfy 
the following needs:

•

Need for a task to have only one busy flag — Because the busy flag for a task is stored in the TSS 
descriptor, each task should have only one TSS descriptor. There may, however, be several task gates that 
reference the same TSS descriptor. 

•

Need to provide selective access to tasks — Task gates fill this need, because they can reside in an LDT and 
can have a DPL that is different from the TSS descriptor's DPL. A program or procedure that does not have 
sufficient privilege to access the TSS descriptor for a task in the GDT (which usually has a DPL of 0) may be 
allowed access to the task through a task gate with a higher DPL. Task gates give the operating system greater 
latitude for limiting access to specific tasks.

•

Need for an interrupt or exception to be handled by an independent task — Task gates may also reside 
in the IDT, which allows interrupts and exceptions to be handled by handler tasks. When an interrupt or 
exception vector points to a task gate, the processor switches to the specified task.

Figure 7-7 illustrates how a task gate in an LDT, a task gate in the GDT, and a task gate in the IDT can all point to 
the same task.

7.3 TASK 

SWITCHING

The processor transfers execution to another task in one of four cases:

•

The current program, task, or procedure executes a JMP or CALL instruction to a TSS descriptor in the GDT.

•

The current program, task, or procedure executes a JMP or CALL instruction to a task-gate descriptor in the 
GDT or the current LDT.

Figure 7-7.  Task Gates Referencing the Same Task

LDT

Task Gate

TSS

GDT

TSS Descriptor

IDT

Task Gate

Task Gate