⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 s07_06.htm

📁 Programmer s Reference Manual is an improtant book on Intel processor architecture and programming.
💻 HTM
字号:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"><HTML><HEAD><TITLE>80386 Programmer's Reference Manual -- Section 7.6</TITLE></HEAD><BODY><B>up:</B> <A HREF="c07.htm">Chapter 7 -- Multitasking</A><BR><B>prev:</B> <A HREF="s07_05.htm">7.5  Task Switching</A><BR><B>next:</B> <A HREF="s07_07.htm">7.7  Task Address Space</A><P><HR><P><H1>7.6  Task Linking</H1>The back-link field of the TSS and the NT (nested task) bit of the flagword together allow the 80386 to automatically return to a task that <A HREF="CALL.htm">CALL</A>edanother task or was interrupted by another task. When a <A HREF="CALL.htm">CALL</A> instruction, aninterrupt instruction, an external interrupt, or an exception causes aswitch to a new task, the 80386 automatically fills the back-link of the newTSS with the selector of the outgoing task's TSS and, at the same time,sets the NT bit in the new task's flag register. The NT flag indicateswhether the back-link field is valid. The new task releases control byexecuting an <A HREF="IRET.htm">IRET</A> instruction. When interpreting an <A HREF="IRET.htm">IRET</A>, the 80386 examinesthe NT flag. If NT is set, the 80386 switches back to the task selected bythe back-link field. Table 7-2 summarizes the uses of these fields.<PRE>Table 7-2. Effect of Task Switch on BUSY, NT, and Back-LinkAffected Field      Effect of JMP      Effect of            Effect of                    Instruction        CALL Instruction     IRET InstructionBusy bit of         Set, must be       Set, must be 0       Unchanged,incoming task       0 before           before               must be setBusy bit of         Cleared            Unchanged            Clearedoutgoing task                          (already set)NT bit of           Cleared            Set                  Unchangedincoming taskNT bit of           Unchanged          Unchanged            Clearedoutgoing taskBack-link of        Unchanged          Set to outgoing      Unchangedincoming task                          TSS selectorBack-link of        Unchanged          Unchanged            Unchangedoutgoing task</PRE><H2>7.6.1  Busy Bit Prevents Loops</H2>The B-bit (busy bit) of the TSS descriptor ensures the integrity of theback-link. A chain of back-links may grow to any length as interrupt tasksinterrupt other interrupt tasks or as called tasks call other tasks. Thebusy bit ensures that the CPU can detect any attempt to create a loop. Aloop would indicate an attempt to reenter a task that is already busy;however, the TSS is not a reentrable resource.<P>The processor uses the busy bit as follows:<OL><LI> When switching to a task, the processor automatically sets the busybit of the new task.<LI> When switching from a task, the processor automatically clears thebusy bit of the old task if that task is not to be placed on theback-link chain (i.e., the instruction causing the task switch is <A HREF="JMP.htm">JMP</A>or <A HREF="IRET.htm">IRET</A>). If the task is placed on the back-link chain, its busy bitremains set.<LI> When switching to a task, the processor signals an exception if thebusy bit of the new task is already set.</OL>By these actions, the processor prevents a task from switching to itself orto any task that is on a back-link chain, thereby preventing invalid reentryinto a task.<P>The busy bit is effective even in multiprocessor configurations, becausethe processor automatically asserts a bus lock when it sets or clears thebusy bit. This action ensures that two processors do not invoke the sametask at the same time . (Refer to <A HREF="c11.htm">Chapter 11</A>   for more on multiprocessing.)<H2>7.6.2  Modifying Task Linkages</H2>Any modification of the linkage order of tasks should be accomplished onlyby software that can be trusted to correctly update the back-link and thebusy-bit. Such changes may be needed to resume an interrupted task beforethe task that interrupted it. Trusted software that removes a task from theback-link chain must follow one of the following policies:<OL><LI> First change the back-link field in the TSS of the interrupting task,then clear the busy-bit in the TSS descriptor of the task removed fromthe list.<LI> Ensure that no interrupts occur between updating the back-link chainand the busy bit.</OL><P><HR><P><B>up:</B> <A HREF="c07.htm">Chapter 7 -- Multitasking</A><BR><B>prev:</B> <A HREF="s07_05.htm">7.5  Task Switching</A><BR><B>next:</B> <A HREF="s07_07.htm">7.7  Task Address Space</A></BODY>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -