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. Android自己主动提示文本框(AutoCompleteTextView)

    自己主动提示文本框(AutoCompleteTextView)能够加强用户体验,缩短用户的输入时间(百度的搜索框就是这个效果). 首先.在xml中定义AutoCompleteTextView控件: a ...

  2. 【智能家居篇】wifi网络结构(下)

    转载请注明出处:http://blog.csdn.net/Righthek 谢谢. 因为WIFI网络具有移动性,同一时候WIFI以无线电波作为传输媒介,这样的媒介本质上是开放的,且easy被拦截,不论 ...

  3. 稀疏表示 Sparse Representation

    稀疏表示_百度百科 https://baike.baidu.com/item/%E7%A8%80%E7%96%8F%E8%A1%A8%E7%A4%BA/16530498 信号稀疏表示是过去近20年来信 ...

  4. 浏览器对MP4视频 帧宽度 高度的兼容性

    传入oss后 或者 本地 拖动到   浏览器 谷歌 都不能播放 Edge 可以播放 但 Edge不支持 本地拖入 播放 搜狗浏览器 同谷歌

  5. the “identity” of an object

    2. Built-in Functions — Python 3.6.5 documentation https://docs.python.org/3.6/library/functions.htm ...

  6. HDU 1517:A Multiplication Game

    A Multiplication Game Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Ot ...

  7. cmd 高级用法

    1. 查看服务(service)信息 查看所有启动的服务信息: C:\Users\hasee>net start 根据启动的服务名,进一步对其启动和关闭: C:\Users\hasee>n ...

  8. ANT-普通替换和正则替换

    ant提供了两个指令用于编译时修改文件,好处就不说了 ,就说说如何使用吧. replaceregexp 和 replace的区别就和java中String replace和replaceAll一样 , ...

  9. RDA CoreDump 实例

    UMF进程的Coredump问题追踪: 通河code开机DUMP问题 现象: 开机Dump,原因:_MAINAPP_SW_Init()调用了Factory_Ver_Debug()内存溢出. 分析流程: ...

  10. 如何在linux 32位机器编译64位程序

    编译64位程序,不一定要编译机器是64位的,但是32位机器默认安装的gcc编译环境还是不能用来编译64位程序. 编译64位程序,需要加上-m64编译器参数,默认安装的gcc已经支持该参数,但是缺少64 ...