-2

I don't understand. Isn't this the whole idea of multi-threading?

Edit: Question modified from "Why two threads within the same process cannot run simultaneously on two processors?".

Vishnu Vivek
  • 1,819
  • 1
  • 20
  • 30

1 Answers1

2

In the article you link to, it lists this as a limitation of user-level threads (that are implemented by an application itself, without being backed by OS-level threads).

That's correct, but it does not apply to "real" threads. The OS is free to schedule them across multiple processors.

Now that most operating systems have robust support for multithreading, I believe that those user-level threads are a thing of the past.

So, yes, the whole point of multi-threading is to be able to run code in parallel on as many CPU as you want to assign to it. And "user-level threads" were a workaround for platforms without proper native thread support, and it was limited in the way you describe (no multiple CPU for a single application process).

Thilo
  • 257,207
  • 101
  • 511
  • 656
  • I mean threads that are exposed to and scheduled by the operating system. "Kernel-level" sounds a bit ambiguous (those are still threads that run application code). – Thilo Nov 24 '15 at 01:09
  • I believe user level threads still exist. Even now we do a lot of multi-threading in .Net and java, for better response time. – Vishnu Vivek Nov 24 '15 at 01:10
  • JVM have not been using "green threads" (user-level threads) for ages. A Java Thread is backed by an OS-level thread. http://stackoverflow.com/questions/5713142/green-threads-vs-non-green-threads – Thilo Nov 24 '15 at 01:11
  • Also, according to the image in the link, I believe the user level threads are the ones which are compiled into OS level threads. Is that right? – Vishnu Vivek Nov 24 '15 at 01:13
  • "user-level thread" means that the application itself schedules thread execution, i.e. which thread gets assigned to run on the "real" threads (there could be more than one in what the article calls "combined approach") provided by the operating system. – Thilo Nov 24 '15 at 01:17