为什么不使用可运行线程的完整列表,而不是仅使用可运行但未运行的线程?
我正在考虑多处理背后的概念,并且我试图找出为什么使用包含所有未运行的可运行线程的就绪列表(而不是列表)的原因。所有可运行的线程的数据结构的头部都是正在运行的线程?
感谢您的意见。
编辑:让我澄清一下。据我所知,线程包使用就绪列表来标识那些准备运行的进程,而正在运行的进程则由一个单独的变量来标识。为什么他们不将正在运行的进程包含在就绪列表数据结构中,并将正在运行的线程放在该结构的头部,从而使线程包包含所有内容。多处理会导致这个设计方案出现问题吗?
I'm considering the concepts behind multiprocessing, and I'm trying to come up with some reason why a ready list is used that contains all runnable threads that aren't running, as opposed to a list of all runnable threads with the head of the data structure being the running thread(s)?
Thanks for your opinions.
EDIT: Let me clarify. As far as I know, thread packages use a ready list to identify those processes that are ready to run, while the running process is identified by a separate variable. Why don't they just include the running processes in the ready list data structure with the running thread at the head of the structure, making the thread package all inclusive. Would multiprocessing cause problems in this design scheme?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
因为一个线程一次只能运行在一个处理器(核心)上。准备运行的线程列表(实际上是队列)主要由调度程序在查找应该运行的线程时使用;如果一个线程已经在一个 CPU 上运行,则它不能同时在另一个 CPU 上运行,因此调度程序不想查看它(当时 - 稍后的某个时候)它没有运行并且有资格再次运行,它会再次关心它......)
Because a thread can only run on one processor (core) at a time. The list (queue, really) of threads that are ready to run is used primarily by the scheduler when it's looking for what thread it should run; if a thread is already running on one CPU, it can't be run on another CPU at the same time, so the scheduler does not want to look at it (at that time -- sometime later when it's not running and eligible to run again, it will care about it again...)