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. 慎用Outline ,UGUI Outline实现原理分析

    使用 UGUI 制作背包的时候.同事发现假设背包中加入了大量的物品.比方两百个.Unity就会出错,提示 Canvas element contains more than 65535 vertice ...

  2. DG备库磁盘空间满导致无法创建归档

    上周五去某客户那里做数据库巡检.是window 2008系统上10g的一套NC系统的库,已经配置了DG,可是巡检时发现数据库报错: Tue Nov 11 10:13:57 2014 LNS: Stan ...

  3. openstack (4)---部署Glance镜像服务,Nova计算服务

    一.Glance Glance是Openstack项目中负责镜像管理的模块,其功能包括虚拟机镜像的查找.注册和检索等. Glance提供Restful API可以查询虚拟机镜像的metadata及获取 ...

  4. DOM 事件类

    DOM事件的级别: DOM级别一共可以分4个级别:DOM0级.DOM1级. DOM2级 .DOM3级.而DOM事件级别分为3个级别:DOM0级事件处理.DOM2级事件处理.DOM3级事件处理 1. D ...

  5. windows server 证书的颁发与IIS证书的使用 Dapper入门使用,代替你的DbSQLhelper Asp.Net MVC中Action跳转(转载)

    windows server 证书的颁发与IIS证书的使用   最近工作业务要是用服务器证书验证,在这里记录下一. 1.添加服务器角色 [证书服务] 2.一路下一步直到证书服务安装完成; 3.选择圈选 ...

  6. OpenStack QA

    1 能用devstack部署生产环境的OpenStack吗? 不能,记着,不能!有些选项对生产环境不合适.生产环境能够考虑使用Crowbar部署OpenStack.相关文档例如以下:http://op ...

  7. 2015 Multi-University Training Contest 4 1001 Olympiad

    代码: #include<cstdio> #include<cstring> #include<set> using namespace std; int vis[ ...

  8. document.getElementsByClassName("head")[0].parentElement

    document.getElementsByClassName("head")[0].parentElement

  9. ubuntu安装virtualbox

    1.下载 2.sudo dpkg -i virtualbox-5.2_5.2.10-122088_Ubuntu_xenial_amd64.deb $sudo dpkg -i virtualbox-5. ...

  10. Python机器学习算法 — 支持向量机(SVM)

    SVM--简介 <α∗j<C,可得:          构造决策函数:  5.求最优解         要求解的最优化问题如下:          考虑使用序列最小最优化算法(SMO,se ...