13.07.2015 Views

iAPX 286 Operating System Writers Guide 1983

iAPX 286 Operating System Writers Guide 1983

iAPX 286 Operating System Writers Guide 1983

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

TASK MANAGEMENTIf the proc~sser, while executing an IRET instruction, finds the NT flag not set, this indicates a returnto an interrupted procedure in the same task. Refer to Chapter 6 for details on interrupt procedures.For CALL and JMP instructions, success of a task switch operation depends on the type field of theTSS descriptor. If the type code is 1, denoting an available task, then the task switch proceeds. If thetype code is 3, denoting a busy task, then an attempt to switch to the task causes an exception. A taskis busy under either of these conditions:• The task is the currently executing task.• The task is on the chain of TSS back-links from the currently executing task. This prevents recursionof task invocations. A task should be restarted only by the the task that interrupts it or by theoperating system after the task has been removed from the back-link chain.If the target task is not busy, the processor takes these steps in executing a task switch:• Saves all registers in current TSS• Loads TR with new TSS descriptor• Loads all registers and flags from new TSS (including LDT register)• If switch is due to CALL (or interrupt), sets NT flag and sets back-link in new TSS to point toprevious TSS• If switch is due to JMP or IRET, changes the old task's descriptor type code to one, indicating thatthe task is no longer busy• Resumes new task where it left off (i.e., CS:IP from new TSS)Note that you cannot pass parameters by an intertask CALL. It is possible to share data between tasks,however. Chapter 5 takes up this subject.ROLE OF OPERATING SYSTEM IN TASK MANAGEMENTTask switching without operating-system involvement is possible (though not necessarily advisable) instatic systems. Consider the following two application-driven scheduling strategies for static systems:1. A fixed sequence of tasks is defined, and each task, when ready to relinquish the processor, voluntarilycalls or jumps to the next task in sequence. Barring any errors, each task gets a share ofprocessor time.2. All tasks in the system service external events. The interrupt mechanism of the <strong>iAPX</strong> <strong>286</strong>, bymeans of interrupt tasks, causes task initiation in real-time response to those events.Strategy I is not viable in a highly protected system. Errors do happen. An erroneous program mighteasily skip a task entirely. A programming error that causes a tight loop in one task would prevent allother tasks from being serviced.Strategy 2 can be adequate by itself for certain real-time systems with a static mix of tasks. Taskswitching by interrupt is usable in dynamic systems, too, but rarely do all tasks in a dynamic systemdeal exclusively with interrupts. Therefore, in dynamic systems, in highly protected systems, and insystems with tasks that do not provide real-time processing, the operating system may need to assistthe processor with task switching.4-4 121960-001

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!