User-level threads for threading

半世苍凉 提交于 2021-01-29 03:11:04

问题


From the Tanenbaum OS book it is mentioned the following:

"in user level threads, if a thread starts running, no other thread in that process will ever run unless the first thread voluntarily gives up the CPU".

That means threads are going to run one after the other (sequently) not in parallel. So what is the advantage of the user-level threads?


回答1:


There are two concepts of multitasking in a single process multiple thread environment.

  1. A single thread execute in time slice of the process. And that thread takes care of scheduling of other threads.
  2. OS takes scheduling decision of process threads and might run them in parallel on different core.

You are talking about approach 1. Yes It has no advantage of multi-threading; but it let many threads / programs run one by one and give you "multitasking" (virtually).



来源:https://stackoverflow.com/questions/40878130/user-level-threads-for-threading

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!