返回 |
Chapter 4
This chapter presents the interface of the Intel Architecture MMX technology to the operating system.
SYSTEM PROGRAMMING MODEL4.1 CONTEXT SWITCHING
This section describes the behavior of operating systems during context switching.
Different operating systems take different approaches for state-saving:
The existing task switch code for IA implementations (including floating-point code) does not change for systems that include MMX code.
4.1.1 Cooperative Multitasking Operating System
In a cooperative operating system, application tasks can predetermine when it is about to be switched out. Tasks can prepare in advance for the switch.
Application programmers must know whether the operating system performs a state save or whether it is their responsibility to perform a state save.
4.1.2 Preemptive Multitasking Operating System
In a preemptive multitasking operating system, the application cannot know when it is preempted. Applications cannot prepare in advance for task switching. The operating system is responsible for saving and restoring the state when necessary.
The IA MMX technology was defined to support the same state-saving and restoring techniques as the floating-point state-saving and restoring techniques. Existing operating systems can continue to run without modifications.
Figure 4-1 illustrates an example of an operating system implementing floating-point or MMX state saving.
Detecting when to save the FP or MMX state needs to be saved is the same process used for detecting when the floating-point state needs to be saved. If CR0.TS=1 (task switch bit in control register 0), then the next FP or MMX instruction generates exception Int 7.
Table 4-1. Effect of the FP and MMX Instructions on the FP Tag Word | |||
MMX | All (except EMMS) | All registers' tags are set to zeros (00). | 00, 01, 10 |
MMX | EMMS | All registers' tags are set to ones (11). | 11 |
FP | All (except FRSTOR, FLDENV) | Individual register tag is set to 00 or 11. | Each register's tags are set to 00, 11, 01 or 10. |
FP | FRSTOR, FLDENV | All registers' tags are set to 00 or 11 or 01 or 10. | Each register's tags are set to 00, 11, 01 or 10. |
Table 4-2. Effects of MMX Instruction on FP State | |||||
MMX register read from MMX register (MMn) | All fields set to 00 (Valid) | 000 | Unchanged | Unchanged | Unchanged |
MMX register write to MMX register (MMn) | All fields set to 00 (Valid) | 000 | Unchanged | Set to ones (11) | Overwritten |
EMMS | All fields set to 11 (Empty) | 000 | Unchanged | Unchanged | Unchanged |
返回 |
All right reserved by Fan Yipeng. |