线程上下文切换Vs.过程上下文切换 [英] Thread context switch Vs. process context switch

查看:232
本文介绍了线程上下文切换Vs.过程上下文切换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以告诉我在两种情况下到底做了什么吗?他们每个人的主要费用是多少?

Could any one tell me what is exactly done in both situations? What is the main cost each of them?

推荐答案

线程切换和进程切换之间的主要区别在于,在线程切换期间,虚拟内存空间保持不变,而在进程执行期间则不相同转变. 两种类型都涉及将控制权移交给操作系统内核以执行上下文切换.切入和切出OS内核的过程以及切出寄存器的成本是执行上下文切换的最大固定成本.

The main distinction between a thread switch and a process switch is that during a thread switch, the virtual memory space remains the same, while it does not during a process switch. Both types involve handing control over to the operating system kernel to perform the context switch. The process of switching in and out of the OS kernel along with the cost of switching out the registers is the largest fixed cost of performing a context switch.

更模糊的代价是上下文切换使处理器缓存机制混乱.基本上,当您进行上下文切换时,处理器在高速缓存中记住"的所有内存地址实际上将变得无用.此处的一大区别是,当您更改虚拟内存空间时,处理器的转换后备缓冲区(TLB)或同等功能将被清空,从而使内存访问在一段时间内变得更加昂贵.在线程切换期间不会发生这种情况.

A more fuzzy cost is that a context switch messes with the processors cacheing mechanisms. Basically, when you context switch, all of the memory addresses that the processor "remembers" in its cache effectively become useless. The one big distinction here is that when you change virtual memory spaces, the processor's Translation Lookaside Buffer (TLB) or equivalent gets flushed making memory accesses much more expensive for a while. This does not happen during a thread switch.

这篇关于线程上下文切换Vs.过程上下文切换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆