Green goblin
Green goblin

Reputation: 9996

If one thread is busy on I/O will the entire process be blocked

In a multi-threaded process,If one thread is busy on I/O will the entire process be blocked?

AFAIK, it totally depends on programmer that how they manage the threads inside the programs. If another thread is there with no I/O, processor will never sit idle & start executing this thread. However, process in split threads such that one thread waits for the result of the other, the the entire process will be blocked.

Please comment if more information needs to be added. Does there exist any other explaination?

Upvotes: 4

Views: 2945

Answers (1)

Konrad Reiche
Konrad Reiche

Reputation: 29493

If the process has only one thread, then yes.

If the process has multiple threads, then normally no if the operating system supports multithreading.

This question can also be addressed in terms of the underlying implementation of user threads. There are different models for multithreading models, in order to implement user threads they have to be mapped to a kernel thread:

  • Many-to-One: Many user threads to one kernel thread

  • One-to-One: Each user thread is assigned to a kernel thread.

  • Many-to-Many: Many user threads are split on different kernel threads.

In the many-to-one case, a single block-operation (system call) within the thread can block the whole process. This disadvantage is not present in the one-to-one model.

Upvotes: 6

Related Questions