多任务和缓存
多任务和nbsp;缓存 假设我一次正在运行两个程序,一个媒体播放器在玩MP3和视频游戏。 目前,让我们假设系统的其他核心与其他程序一起取出,我的问题是关于CPU缓存。
每当计算机必须更改上下文以运行不同的程序时,是否必须冲洗CPU缓存?
我想进一步了解有关操作系统的更多问题的频率,并且有人对这种问题有任何良好的在线参考。
Multitasking and cache
let's say I'm running two programs at once, a media player playing an MP3 and a video game.
Let's assume for the moment that the other cores of the system are taken out with other programs my question is about the CPU cache.
Every time the computer has to change contexts to run the different programs does it have to flush the CPU cache?
How often does this happen and does anyone have any good online references for this sort of question I'm looking to learn more about operating systems.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
哪个缓存(在哪个CPU中)?
某些缓存(例如80x86 CPU中的L2高速缓存和L3高速缓存)在更改上下文时被物理索引,并且不会冲洗(因为当您查看物理RAM和物理地址时,“上下文”没有影响);但是“最近使用的驱逐”(及其变化)倾向于意味着,在短时间内数据的数据被驱逐出来,以在当前程序使用的数据中腾出空间。
某些缓存(例如L1指令缓存,跟踪缓存,“虚拟内存翻译的高速缓存”/TLB,...)可能会或可能不会被冲洗。有时,它们用某种ID标记并且没有冲洗(因此,具有ID#45的程序的内容被简单地忽略了,但可能由于ID#67的程序运行时的“最少最近使用”而被驱逐出现)。有时,OS出于安全目的显式冲洗(例如幽灵脆弱性缓解)。
Which cache (in which CPU)?
Some caches (e.g. L2 cache and L3 cache in 80x86 CPUs) are physically indexed and not flushed when contexts are changed (because the "context" has no influence when you're looking at physical RAM and physical addresses); but "least recently used eviction" (and variations thereof) tend to mean that over a short period of time data for the previous program is evicted to make room in the cache for data used by the current program.
Some caches (e.g. L1 instruction cache, trace cache, "cache of virtual memory translations"/TLB, ...) might or might not be flushed. Sometimes they're tagged with some kind of ID and not flushed (so that stuff for the program with ID #45 is simply ignored but possibly evicted due to "least recently used" when the program with ID #67 is running). Sometimes the OS explicitly flushes for security purposes (e.g. spectre vulnerability mitigations).