问题描述
我阅读了以下声明:
我想知道:
- 为什么Linux不使用硬件支持进行上下文切换?
- 硬件方法不是比软件方法快得多吗?
- 是否有任何可以利用硬件上下文切换的操作系统? Windows是否使用它?
最后,一如既往,感谢您的耐心等待和回复.
At last and as always, thanks for your patience and reply.
-----------已添加--------------
-----------Added--------------
http://wiki.osdev.org/Context_Switching 得到了一些解释.
像我一样困惑的人们可以看看它. 8 ^)
People as confused as me could take a look at it. 8^)
推荐答案
对于硬件多任务处理,x86 TSS非常慢,与软件任务切换相比,几乎没有任何好处. (实际上,我认为手动操作会击败TSS很多次)
The x86 TSS is very slow for hardware multitasking and offers almost no benefits when compared to software task switching. (In fact, I think doing it manually beats the TSS a lot of times)
TSS还以烦人且乏味而著称,它不便于移植,甚至不能移植到x86-64. Linux旨在于多种体系结构上工作,因此他们可能选择使用软件任务切换,因为它可以以与机器无关的方式编写.而且,软件任务切换为可完成的工作提供了更多功能,并且与TSS相比,通常更易于设置.
The TSS is known also for being annoying and tedious to work with and it is not portable, even to x86-64. Linux aims at working on multiple architectures so they probably opted to use software task switching because it can be written in a machine independent way. Also, Software task switching provides a lot more power over what can be done and is generally easier to setup than the TSS is.
我相信Windows 3.1使用了TSS,但至少NT> 5内核没有使用.我不知道任何使用TSS的类似Unix的操作系统.
I believe Windows 3.1 used the TSS, but at least the NT >5 kernel does not. I do not know of any Unix-like OS that uses the TSS.
请注意,TSS 是强制性的.操作系统要做的事情是创建一个(每个处理器)单个TSS条目,并且每当他们需要切换任务时,它们都只是更改了该单个TSS.而且,通过软件任务切换在TSS中使用的唯一字段是ESP0
和SS0
.这用于从环3代码到达环0进行中断.没有TSS,就不会有已知的Ring 0堆栈,这当然会导致GPF并最终导致三重故障.
Do note that the TSS is mandatory. The thing that OSs do though is create a single TSS entry(per processor) and everytime they need to switch tasks, they just change out this single TSS. And also the only fields used in the TSS by software task switching is ESP0
and SS0
. This is used to get to ring 0 from ring 3 code for interrupts. Without a TSS, there would be no known Ring 0 stack which would of course lead to a GPF and eventually triple fault.
这篇关于Linux为什么不通过TSS使用硬件上下文切换?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!