什么是上下文切换时间?
我对上下文切换有疑问。 在多线程中,当发生上下文切换时,两次上下文切换之间的时间间隔是多少?是固定的时间间隔吗?
I have a doubt in context switching.
In multi threading, when the context switching occurs, what will be the time between two context switches? Is it fixed time interval?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这实际上取决于操作系统和情况。您必须阅读一般调度以及您使用的特定线程技术:< a href="http://en.wikipedia.org/wiki/List_of_algorithms#Scheduling" rel="nofollow noreferrer">这里有一个很好的列表。
在考虑线程时,如果其他进程需要 CPU 时间,则实际的挂起时间间隔可能会发生变化,从而从运行线程的进程中获取时间。
话虽这么说,有一些不错的用于测量该时间的 C 代码示例。
It is really OS and situation dependent. You'll have to read about scheduling in general and about the specific threading technology you use: there is a nice list here.
When considering threads, the real wall-time intervals might change if other processes need CPU time, by that taking time from the process running the threads.
That being said, there are some nice C code samples to measure that time.