【问题标题】:MINIX doesn't take advantage of x86 task switching, right?MINIX 没有利用 x86 任务切换,对吧?
【发布时间】:2021-10-20 05:28:40
【问题描述】:

我正在研究MINIX book version (3.1.0) source code,发现MINIX 3没有使用cpu的任务切换功能,它只是执行一个普通的iret,没有设置NT标志。 对吗?

_restart:

! Restart the current process or the next process if it is set. 

    cmp (_next_ptr), 0      ! see if another process is scheduled
    jz  0f
    mov     eax, (_next_ptr)
    mov (_proc_ptr), eax    ! schedule new process 
    mov (_next_ptr), 0
0:  mov esp, (_proc_ptr)    ! will assume P_STACKBASE == 0
    lldt    P_LDT_SEL(esp)      ! enable process' segment descriptors 
    lea eax, P_STACKTOP(esp)    ! arrange for next interrupt
    mov (_tss+TSS3_S_SP0), eax  ! to save state in process table
restart1:
    decb    (_k_reenter)
    o16 pop gs
    o16 pop fs
    o16 pop es
    o16 pop ds
    popad
    add esp, 4      ! skip return adr
    iretd           ! continue process

【问题讨论】:

    标签: x86 operating-system kernel minix


    【解决方案1】:

    是的;这对几乎所有 x86 操作系统都是通用的(尽管我即将发布一个试图将其用于咯咯笑的操作系统)。整个 NT + 追逐反向链接是一个巧妙的想法,但实际上使内核更难实现,而且显然收益很少。 386 保护模型是通过 iapx432 的 80286 继承而来的。 432 是在处理器中实现的面向对象、基于能力的保护模型。请注意,Google 的略带紫色的操作系统使用了这些流行语。

    与 432 不同,80286(和后续版本)插入了一个 unix-y 系统调用模型,这使得整个任务链接、嵌套任务成为操作系统必须撤消的东西;所以更容易完全避免它,并将其视为古怪的 68k。

    现在 Robert Bedichek 回到了英特尔,我想知道我们是否会看到像这样更雄心勃勃的设计,而不是 哦,我们有 8 个解码器单元帮助我们睡了 20 年.

    【讨论】: