4.5 Interprocess communication


Interprocess communication (IPC) is the facility to allow the cooperating processes to communicate with each other. The communicating processes can be on different computers connected with a network. Examples of IPC are:
Message-passing system. It uses at least the two operations send(message) and receive(message).
The link among processes is not a physical communication link but a logical link.
Direct communication. There are two types of this communication type: symmetry and asymmetry. In the
symmetry addressing, the sender and the receiver have to name each other. In the asymmetry
addressing, only the sender names the receiver and the receiver does not have to name the sender.
Indirect communication. In indirect communication, the messages are sent to and received from
mailboxes.

Threads
When a process has a single path of execution, then it is called a single-threaded process. The operating system supports multithreading if it can support multiple concurrent paths of execution within a single process.
The advantages of the threads are the following:
It takes far less time to create a new thread than to create a brand-new process.
It takes less time to terminate a thread than a process.

4.5 Interprocess communication


It takes less time to switch between two threads within the same process than to switch between
processes.
Threads enhance efficiency in communication between different executing programs because threads
within the same process share memory and files.

Examples of using threads in a single-user multiprocessing system:
Foreground and background work.
Asynchronous processing.
Speed of execution.
Modular program structure.

There are two types of threads user-level threads (ULTs) and kernel-level threads (KLTs). In ULTs, the thread management is done using the process and not the kernel. The process has a thread library which can perform threads management.

The advantages of using ULTs are the following:
The thread management is done in the process and it is not required to switch to the kernel mode. That
saves the switch between the user mode and the kernel mode.

4.5 Interprocess communication


The threading scheduling can be done by the application without disturbing the kernel.
ULTs can run on any operating system. The kernel does not have to have special features support ULTs.

The disadvantages of using ULTs are the following:
When one thread is blocked because of blocked system call, all the threads with the process are
blocked.
In a pure ULT strategy, only one processor is assigned to a process. So, only one thread within the
process can be executed.

In pure KLTs, the thread management is done by the kernel. Windows is an example of this approach. KLTs approach has the following advantages:
The kernel can simultaneously schedule multiple threads from the same process on multiple processors.
If one thread in a process is blocked, the kernel can schedule another thread of the same process.
The kernel routines can be also multithreaded.

The main disadvantage of KLT approach is that there is time spent to transfer of control from one thread to another within the same process because it requires a mode switch to the kernel.

4.5 Interprocess communication


ULT and KLT facilities can be combined in some operating systems. In a combined approach, threads in the same application can run in parallel on multiple processors. In addition, a blocking system call does not block the entire process.