2

For Kernel-Level-Threads when one thread blocks for some I/O another thread is free to run, but in User-Level-Threads what happens if one thread is blocked?

Will that process remain blocked i.e. no other thread will execute or another thread will be scheduled to run. What happens exactly?

Luv
  • 5,381
  • 9
  • 48
  • 61
  • I assume when you say user-level-threads you are talking about "green-threads"? http://en.wikipedia.org/wiki/Green_threads – Gray May 29 '12 at 14:15
  • Related to http://stackoverflow.com/questions/1178785/user-thread-and-kernel-thread – Gray May 29 '12 at 14:25

1 Answers1

3

User-level threads are pieces of user code that execute in sequential fashion - one thread runs for a while then transfers the control to another thread and so on. If one of those threads make a syscall that blocks then the process as a whole blocks. User-level threading looks like a single threaded process to the kernel. No concurrent scheduling on multiple CPUs is possible.

The main advantage of kernel-level threads is that they run independently from one another and can be scheduled on different CPUs. If one blocks, others continue to execute.

Hristo Iliev
  • 72,659
  • 12
  • 135
  • 186
  • But as far as i know by making use of jacketing we can covert a blocking system call into a non-blocking system call for ULT. And thus if one thread blocks, it passes control to another thread(through threads library). – Luv May 29 '12 at 14:24
  • Yes, using nonblocking I/O is one way to circumvent the limitations of user-level threading. But it adds complexity to the code or to the threading library. It's all a matter of tradeoff: what you gain and what you lose if you use one threading method over the other. – Hristo Iliev May 29 '12 at 16:34