7.6 Task Linking 任务链

The back-link field of the TSS and the NT (nested task) bit of the flag word together allow the 80386 to automatically return to a task that CALLed another task or was interrupted by another task. When a CALL instruction, an interrupt instruction, an external interrupt, or an exception causes a switch to a new task, the 80386 automatically fills the back-link of the new TSS 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 indicates whether the back-link field is valid. The new task releases control by executing an IRET instruction. When interpreting an IRET, the 80386 examines the NT flag. If NT is set, the 80386 switches back to the task selected by the back-link field. Table 7-2 summarizes the uses of these fields.

TSS中的后向连接字段和标志字中的NT位一起允许80386自动返回到一个任务,返回的任务是调用任务的调用者(CALLed)或被另一个任务中断的任务。当一个CALL指令、中断指令、内部中断或者异常导致切换到一个新任务时,80386使用切换出去的任务的TSS的选择子来自动填充新TSS的后向连接字段,同时,在新任务的标志寄存器中设置NT位。

NT位表明一个后向连接字段是有效的。新任务通过IRET指令来释放控制权。当解释一条IRET指令时,80386检查NT位。如果NT位被置位,80386通过后向连接位选择切换回的任务。表7-2总结了这些字段的用法。

Table 7-2. Effect of Task Switch on BUSY, NT, and Back-Link

Affected Field      Effect of JMP      Effect of            Effect of

Instruction        CALL Instruction     IRET Instruction

Busy bit of         Set, must be       Set, must be 0       Unchanged,

incoming task       0 before           before               must be set

Busy bit of         Cleared            Unchanged            Cleared

outgoing task                          (already set)

NT bit of           Cleared            Set                  Unchanged

incoming task

NT bit of           Unchanged          Unchanged            Cleared

outgoing task

Back-link of        Unchanged          Set to outgoing      Unchanged

incoming task                          TSS selector

Back-link of        Unchanged          Unchanged            Unchanged

outgoing task

7.6.1 Busy Bit Prevents Loops 忙位阻止循环

The B-bit (busy bit) of the TSS descriptor ensures the integrity of the back-link. A chain of back-links may grow to any length as interrupt tasks interrupt other interrupt tasks or as called tasks call other tasks. The busy bit ensures that the CPU can detect any attempt to create a loop. A loop would indicate an attempt to reenter a task that is already busy; however, the TSS is not a reentrable resource.

TSS描述符的B位(忙位)确保后向连接的完整。当中断任务又中断其他中断任务或当调用任务再调用其他任务时,后向连接链可能增长得很大。忙位确保CPU可以检测任何创建一个循环的企图。循环表明企图重入一个已经在忙的任务;然而,TSS是不可重入资源。

The processor uses the busy bit as follows:

处理器在以下场景使用忙位:

  1. When switching to a task, the processor automatically sets the busy bit of the new task.

当切换到一个任务时,处理器自动设置新任务的忙位。

  1. When switching from a task, the processor automatically clears the busy bit of the old task if that task is not to be placed on the back-link chain (i.e., the instruction causing the task switch is JMP or IRET). If the task is placed on the back-link chain, its busy bit remains set.

当从一个任务切换时,处理器自动清除一个旧任务的忙位,如果那个任务没有被放入到后向连接链中(JMP或IRET指令引起的任务切换)。如果任务被放在后向连接链中,它的忙位将保持设置状态。

  1. When switching to a task, the processor signals an exception if the busy bit of the new task is already set.

当切换到一个任务时,如果新任务的忙位已经被置位,处理器会发送一个异常信号。

By these actions, the processor prevents a task from switching to itself or to any task that is on a back-link chain, thereby preventing invalid reentry into a task.

通过这些动作,处理器阻止一个任务切换到自身或者任何已经在后向连接链中的任务,因此可阻止对任务的无效重入。

The busy bit is effective even in multiprocessor configurations, because the processor automatically asserts a bus lock when it sets or clears the busy bit. This action ensures that two processors do not invoke the same task at the same time . (Refer to Chapter 11 for more on multiprocessing.)

即使在多处理器环境中忙位也是有效的,因为处理器在设置或清除一个忙位时会自动验证一个忙位锁。这个动作确保两个处理器在同一时间不会激活同一个任务。(参见第11章关于多处理器内容。)

7.6.2 Modifying Task Linkages 修改任务连

Any modification of the linkage order of tasks should be accomplished only by software that can be trusted to correctly update the back-link and the busy-bit. Such changes may be needed to resume an interrupted task before the task that interrupted it. Trusted software that removes a task from the back-link chain must follow one of the following policies:

任何对任务顺序连进行的修改都应当谨慎,只有那些被信任可以正确更新后向连接和忙位的软件才能实施。这样的修改对于在中断它的任务之前重启一个被中断的任务可能是需要。可信任的软件从后向连接移除一个任务时必须遵循以下策略:

  1. 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 from the list.

首先,修改正处于中断的任务的TSS的后向连接字段,然后清除从链表中被移除的任务的TSS描述符中的忙位。

  1. Ensure that no interrupts occur between updating the back-link chain and the busy bit.

确保在更新后向连接链和忙位时没有中断发生。

【译】x86程序员手册27-7.6任务链的更多相关文章

  1. 【译】x86程序员手册01

    Intel 80386 Reference Programmer's Manual 80386程序员参考手册 Chapter 1 -- Introduction to the 80386 第1章 - ...

  2. 【译】x86程序员手册03 - 2.1内存组织和分段

    2.1 Memory Organization and Segmentation 内存组织和分段 The physical memory of an 80386 system is organized ...

  3. 【译】x86程序员手册00 - 翻译起因

    从上一次学习MIT的操作系统课程又过去了一年.上次学习并没有坚持下去.想来虽有种种原因,其还在自身无法坚持罢了.故此次再鼓起勇气重新学习,发现课程都已由2014改版为2016了.但大部分内容并没有改变 ...

  4. 【译】x86程序员手册38-10.2实在址模式下的软件初始化

    10.2 Software Initialization for Real-Address Mode   实地址模式的软件初始化 In real-address mode a few structur ...

  5. 【译】x86程序员手册09-第3章程序指令集

    注:觉得本章内容与理解操作系统不直接相关,所以本章并未看完,也就没有翻译完,放在这里中是为了保证手册的完整.有兴趣的人可以去原址查看. https://pdos.csail.mit.edu/6.828 ...

  6. 【译】x86程序员手册05 - 2.3寄存器

    2.3 Registers 寄存器 The 80386 contains a total of sixteen registers that are of interest to the applic ...

  7. 【译】x86程序员手册02 - 基本的程序模式

    Chapter 2 -- Basic Programming Model: 基本的程序模式 Introduces the models of memory organization. Defines ...

  8. 【译】x86程序员手册40-10.5初始化的例子

    10.5 Initialization Example初始化的例子 译注:本来想把这个例子全部注释完,但由于对intel汇编实不熟悉,有太多的伪指令,本人也是免强看懂,所以就不再做翻译了. $TITL ...

  9. 【译】x86程序员手册39-10.3切换到保护模式

    10.3 Switching to Protected Mode  切换到保护模式 Setting the PE bit of the MSW in CR0 causes the 80386 to b ...

  10. 【译】x86程序员手册37-第10章 初始化

    Chapter 10 Initialization 第10章 初始化 After a signal on the RESET pin, certain registers of the 80386 a ...

随机推荐

  1. 【VBA研究】工作表自己主动筛选模式检測

    作者:iamlaosong 用VBA程序处理Excel数据文件.用户的数据文件有时处于自己主动筛选模式,往往导致数据处理不对.为此,须要检測工作表是否处于该模式,假设是,则去掉自己主动筛选.语句例如以 ...

  2. hdu 4291 矩阵幂 循环节

    http://acm.hdu.edu.cn/showproblem.php?pid=4291 凡是取模的都有循环节-----常数有,矩阵也有,并且矩阵的更奇妙: g(g(g(n))) mod 109  ...

  3. windows7 配置 python开发环境

    1.安装python2.7     官网下载,安装,配置环境变量 path,命令行 执行python 2.easy_install 安装 win7 64位必须使用ez_setup.py进行安装. 方法 ...

  4. 远程查看日志-linux

    ssh 连接服务器 ssh user@www.xxx.com -p60022 用户名@ip 端口 进入日志所在目录 cat FILENAME 查看文本文件,P.S. 在查较大文件时为了避免刷屏,请使用 ...

  5. LightTable的结构(二)

    这节主要研究下object的一个属性,behaviors 定义一个behavior需要提供name,trigger,reaction (behavior ::on-close-destroy :tri ...

  6. TC SRM 597 DEV2

    第一次玩TC的SRM,只完成了一题,有点失落,不过还是要把每个问题都研究清楚才是我的本性,呵呵 第一题思路: 任意一个数,不断除掉2以后的剩下的数若相同则YES否则NO 第二题: 最开始判断字母个数是 ...

  7. presentModalViewController和dismissModalViewControllerAnimated的使用总结

    在实际开发中,如果要弹出视图: 我们常用到presentModalViewController方法和dismissModalViewControllerAnimated方法. presentModal ...

  8. 洛谷 P2296 寻找道路 —— bfs

    题目:https://www.luogu.org/problemnew/show/P2296 第一次用 Emacs 对拍,写了半天: 注意那个 is 赋值的地方很容易错,千万别反复赋值: 一道水题写了 ...

  9. JS动态加载JS

    1.直接document.write <script language="javascript">     document.write("<scrip ...

  10. va_start和va_end使用详解(转载)

    转自:http://www.cnblogs.com/hanyonglu/archive/2011/05/07/2039916.html 本文主要介绍va_start和va_end的使用及原理. 在以前 ...