问题
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.
- A single thread execute in time slice of the process. And that thread takes care of scheduling of other threads.
- 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