0% found this document useful (0 votes)
150 views

Interprocess Communication

Interprocess communication allows processes to communicate with each other by transferring data or notifying of events. Common methods of interprocess communication include pipes, sockets, files, shared memory, and message queues. Synchronization methods like semaphores and mutexes are needed to coordinate access to shared resources between processes. The main models of interprocess communication are message passing which uses queues and shared memory which allows direct access to common memory regions.

Uploaded by

Sukhwinder
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
150 views

Interprocess Communication

Interprocess communication allows processes to communicate with each other by transferring data or notifying of events. Common methods of interprocess communication include pipes, sockets, files, shared memory, and message queues. Synchronization methods like semaphores and mutexes are needed to coordinate access to shared resources between processes. The main models of interprocess communication are message passing which uses queues and shared memory which allows direct access to common memory regions.

Uploaded by

Sukhwinder
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Interprocess communication

Interprocess communication is the mechanism provided by the operating system that allows
processes to communicate with each other. This communication could involve a process letting
another process know that some event has occurred or the transferring of data from one
process to another.
A diagram that illustrates interprocess communication is as follows:

Synchronization in Interprocess Communication


Synchronization is a necessary part of interprocess communication. It is either provided by the
interprocess control mechanism or handled by the communicating processes. Some of the
methods to provide synchronization are as follows:

 Semaphore
A semaphore is a variable that controls the access to a common resource by multiple
processes. The two types of semaphores are binary semaphores and counting
semaphores.

 Mutual Exclusion
Mutual exclusion requires that only one process thread can enter the critical section at a
time. This is useful for synchronization and also prevents race conditions.

 Barrier
A barrier does not allow individual processes to proceed until all the processes reach it.
Many parallel languages and collective routines impose barriers.

 Spinlock
This is a type of lock. The processes trying to acquire this lock wait in a loop while
checking if the lock is available or not. This is known as busy waiting because the
process is not doing any useful operation even though it is active.
Approaches to Interprocess Communication
The different approaches to implement interprocess communication are given as follows:

 Pipe
A pipe is a data channel that is unidirectional. Two pipes can be used to create a two-
way data channel between two processes. This uses standard input and output
methods. Pipes are used in all POSIX systems as well as Windows operating systems.

 Socket
The socket is the endpoint for sending or receiving data in a network. This is true for
data sent between processes on the same computer or data sent between different
computers on the same network. Most of the operating systems use sockets for
interprocess communication.

 File
A file is a data record that may be stored on a disk or acquired on demand by a file
server. Multiple processes can access a file as required. All operating systems use files
for data storage.
 Signal
Signals are useful in interprocess communication in a limited way. They are system
messages that are sent from one process to another. Normally, signals are not used to
transfer data but are used for remote commands between processes.

 Shared Memory
Shared memory is the memory that can be simultaneously accessed by multiple
processes. This is done so that the processes can communicate with each other. All
POSIX systems, as well as Windows operating systems use shared memory.

 Message Queue
Multiple processes can read and write data to the message queue without being
connected to each other. Messages are stored in the queue until their recipient retrieves
them. Message queues are quite useful for interprocess communication and are used by
most operating systems.
A diagram that demonstrates message queue and shared memory methods of interprocess
communication is as follows:

Message passing model and shared memory model are models of interprocess communication.
Details about these are given as follows:

Message Passing Process Communication Model


Message passing model allows multiple processes to read and write data to the message queue
without being connected to each other. Messages are stored on the queue until their recipient
retrieves them. Message queues are quite useful for interprocess communication and are used
by most operating systems.
A diagram that demonstrates message passing model of process communication is given as
follows:

In the above diagram, both the processes P1 and P2 can access the message queue and store
and retrieve data.
An advantage of message passing model is that it is easier to build parallel hardware. This is
because message passing model is quite tolerant of higher communication latencies. It is also
much easier to implement than the shared memory model.
However, the message passing model has slower communication than the shared memory
model because the connection setup takes time.

Shared Memory Process Communication Model


The shared memory in the shared memory model is the memory that can be simultaneously
accessed by multiple processes. This is done so that the processes can communicate with each
other. All POSIX systems, as well as Windows operating systems use shared memory.
A diagram that illustrates the shared memory model of process communication is given as
follows:

In the above diagram, the shared memory can be accessed by Process 1 and Process 2.
An advantage of shared memory model is that memory communication is faster as compared to
the message passing model on the same machine.
However, shared memory model may create problems such as synchronization and memory
protection that need to be addressed.
Multithreading allows the execution of multiple parts of a program at the same time. These parts
are known as threads and are lightweight processes available within the process. Therefore,
multithreading leads to maximum utilization of the CPU by multitasking.
The main models for multithreading are one to one model, many to one model and many to
many model. Details about these are given as follows:

One to One Model


The one to one model maps each of the user threads to a kernel thread. This means that many
threads can run in parallel on multiprocessors and other threads can run when one thread
makes a blocking system call.
A disadvantage of the one to one model is that the creation of a user thread requires a
corresponding kernel thread. Since a lot of kernel threads burden the system, there is restriction
on the number of threads in the system.
A diagram that demonstrates the one to one model is given as follows:

Many to One Model


The many to one model maps many of the user threads to a single kernel thread. This model is
quite efficient as the user space manages the thread management.
A disadvantage of the many to one model is that a thread blocking system call blocks the entire
process. Also, multiple threads cannot run in parallel as only one thread can access the kernel
at a time.
A diagram that demonstrates the many to one model is given as follows:

Many to Many Models


The many to many model maps many of the user threads to a equal number or lesser kernel
threads. The number of kernel threads depends on the application or machine.
The many to many does not have the disadvantages of the one to one model or the many to
one model. There can be as many user threads as required and their corresponding kernel
threads can run in parallel on a multiprocessor.
A diagram that demonstrates the many to many model is given as follows:

You might also like