answersLogoWhite

0


Best Answer

The 80386 switches execution to another task in any of four cases: 1. The current task executes a JMP or CALL that refers to a TSS

descriptor.

2. The current task executes a JMP or CALL that refers to a task gate.

3. An interrupt or exception vectors to a task gate in the IDT.

4. The current task executes an IRET when the NT flag is set.

JMP, CALL, IRET, interrupts, and exceptions are all ordinary mechanisms of the 80386 that can be used in circumstances that do not require a task switch. Either the type of descriptor referenced or the NT (nested task) bit in the flag word distinguishes between the standard mechanism and the variant that causes a task switch.

To cause a task switch, a JMP or CALL instruction can refer either to a TSS descriptor or to a task gate. The effect is the same in either case: the 80386 switches to the indicated task.

An exception or interrupt causes a task switch when it vectors to a task gate in the IDT. If it vectors to an interrupt or trap gate in the IDT, a task switch does not occur. Refer to Chapter 9 for more information on the interrupt mechanism.

Whether invoked as a task or as a procedure of the interrupted task, an interrupt handler always returns control to the interrupted procedure in the interrupted task. If the NT flag is set, however, the handler is an interrupt task, and the IRET switches back to the interrupted task.

A task switching operation involves these steps:

  1. Checking that the current task is allowed to switch to the designated task. Data-access privilege rules apply in the case of JMP or CALL instructions. The DPL of the TSS descriptor or task gate must be less than or equal to the maximum of CPL and the RPL of the gate selector. Exceptions, interrupts, and IRETs are permitted to switch tasks regardless of the DPL of the target task gate or TSS descriptor.
  2. Checking that the TSS descriptor of the new task is marked present and has a valid limit. Any errors up to this point occur in the context of the outgoing task. Errors are restartable and can be handled in a way that is transparent to applications procedures.
  3. Saving the state of the current task. The processor finds the base address of the current TSS cached in the task register. It copies the registers into the current TSS (EAX, ECX, EDX, EBX, ESP, EBP, ESI, EDI, ES, CS, SS, DS, FS, GS, and the flag register). The EIP field of the TSS points to the instruction after the one that caused the task switch.
  4. Loading the task register with the selector of the incoming task's TSS descriptor, marking the incoming task's TSS descriptor as busy, and setting the TS (task switched) bit of the MSW. The selector is either the operand of a control transfer instruction or is taken from a task gate.
  5. Loading the incoming task's state from its TSS and resuming execution. The registers loaded are the LDT register; the flag register; the general registers EIP, EAX, ECX, EDX, EBX, ESP, EBP, ESI, EDI; the segment registers ES, CS, SS, DS, FS, and GS; and PDBR. Any errors detected in this step occur in the context of the incoming task. To an exception handler, it appears that the first instruction of the new task has not yet executed.

Note that the state of the outgoing task is always saved when a task switch occurs. If execution of that task is resumed, it starts after the instruction that caused the task switch. The registers are restored to the values they held when the task stopped executing.

Every task switch sets the TS (task switched) bit in the MSW (machine status word). The TS flag is useful to systems software when a coprocessor (such as a numerics coprocessor) is present. The TS bit signals that the context of the coprocessor may not correspond to the current 80386 task. Chapter 11 discusses the TS bit and coprocessors in more detail.

Exception handlers that field task-switch exceptions in the incoming task (exceptions due to tests 4 thru 16 of Table 7-1) should be cautious about taking any action that might load the selector that caused the exception. Such an action will probably cause another exception, unless the exception handler first examines the selector and fixes any potential problem.

The privilege level at which execution resumes in the incoming task is neither restricted nor affected by the privilege level at which the outgoing task was executing. Because the tasks are isolated by their separate address spaces and TSSs and because privilege rules can be used to prevent improper access to a TSS, no privilege rules are needed to constrain the relation between the CPLs of the tasks. The new task begins executing at the privilege level indicated by the RPL of the CS selector value that is loaded from the TSS.

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Why is task-switching a necessary feature of a multitasking?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is process based multitasking?

process-based multitasking is the feature that allows your computer to run two or more programs concurrently.


What is the difference between multitasking and taskswitching?

Multitasking and Task switching are entirely different concepts. Multitasking is all about performing multiple tasks at the same time whereas, Task Switching can relate to moving from one task to another based on priority. Task Switching can be very closely associated to humans, as we have been doing it for quite a while now. While performing your daily tasks, you may be interrupted by another authority, which may lead you to switch tasks for a brief period. The disadvantage is you may lose the level of concentration you had earlier in the beginning. 'Multitasking' on the otherhand is associated with machines performing more than one task at a given time.


Is a multitasking operating system available only for computers manufactured by Apple?

Multitasking, the ability to run several processes at the same time, is a feature of most modern computer operating systems.


What feature enables a windows server 2008 system to run more than one program at the same time?

Multitasking


What is the difference between cooperative multitasking and preemptive multitasking?

Cooperative multitasking is multitasking tohelp someone else, while peemative multitasking is multiaatsking for yourself.


What is a necessary feature for a pattern?

A necessary feature for a pattern is repetition or predictability. Patterns are defined by the regularity in which elements are repeated or follow a specific sequence. Without this feature, it would not be considered a pattern.


What is a necessary feature of pattern in art?

repetition


What side of the brain is used for multitasking Brain multitasking?

Left


What is the unix terminology for multitasking?

Multitasking.


Who is better at multitasking women or men?

girls. there brain is built for multitasking


What are main differences between cooperative multitasking and preemtive multitasking?

Preemptive multitasking is when the operating system preemptively interrupts a current task without cooperation. Cooperative multitasking is when the system must be programmed to do tasks.


Does iOS 4.2.1 have multitasking?

No, but multitasking can be enabled if you Jailbreak your ipod touch. Use greenposi0n.com jailbreak website to download jailbreak program. Jailbreak iPod touch Then use loader to download cydia app. go into cydia and search multitasking. then install multitasking enabler. Go into winterboard checkoff the multitasking enable option respring and you will have multitasking.