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

Unit 2 IPC

The document discusses interprocess communication (IPC), which allows processes to communicate with each other. There are two main models of IPC - the shared memory model and message passing model. The shared memory model uses shared memory that multiple processes can access simultaneously, while the message passing model involves processes communicating by posting and retrieving messages. The document also outlines several methods for IPC, including pipes, FIFOs, message queues, shared memory, semaphores, signals, and sockets.

Uploaded by

Abhishek Yadav
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
76 views

Unit 2 IPC

The document discusses interprocess communication (IPC), which allows processes to communicate with each other. There are two main models of IPC - the shared memory model and message passing model. The shared memory model uses shared memory that multiple processes can access simultaneously, while the message passing model involves processes communicating by posting and retrieving messages. The document also outlines several methods for IPC, including pipes, FIFOs, message queues, shared memory, semaphores, signals, and sockets.

Uploaded by

Abhishek Yadav
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

INTERPROCESS COMMUNICATION (IPC)

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 transferring of
data from one process to another.
A diagram that illustrates interprocess communication is as follows:

The models of interprocess communication are as follows:


1. Shared Memory Model
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.
Advantage of Shared Memory Model
Memory communication is faster on the shared memory model as compared to the
message passing model on the same machine.
Disadvantages of Shared Memory Model
Some of the disadvantages of shared memory model are as follows:

 All the processes that use the shared memory model need to make sure that
they are not writing to the same memory location.
 Shared memory model may create problems such as synchronization and
memory protection that need to be addressed.
2. Message Passing Model
Multiple processes can 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.
Advantage of Messaging Passing Model
The message passing model is much easier to implement than the shared memory
model.
Disadvantage of Messaging Passing Model
The message passing model has slower communication than the shared memory
model because the connection setup takes time.
A diagram that demonstrates the shared memory model and message passing model
is given as follows
Methods in Interprocess Communication

Inter-process communication (IPC) is set of interfaces, which is usually


programmed in order for the programs to communicate between series of
processes. This allows running programs concurrently in an Operating System.
These are the methods in IPC:

1. Pipes − Communication between two related processes. The mechanism is


half duplex meaning the first process communicates with the second process.
To achieve a full duplex i.e., for the second process to communicate with the
first process another pipe is required.
2. FIFO − Communication between two unrelated processes. FIFO is a full
duplex, meaning the first process can communicate with the second process and
vice versa at the same time.
3. Message Queues − Communication between two or more processes with full
duplex capacity. The processes will communicate with each other by posting a
message and retrieving it out of the queue. Once retrieved, the message is no
longer available in the queue.
4. Shared Memory − Communication between two or more processes is
achieved through a shared piece of memory among all processes. The shared
memory needs to be protected from each other by synchronizing access to all
the processes.
5. Semaphores − Semaphores are meant for synchronizing access to multiple
processes. When one process wants to access the memory (for reading or
writing), it needs to be locked (or protected) and released when the access is
removed. This needs to be repeated by all the processes to secure data.
6. Signals − Signal is a mechanism to communication between multiple
processes by way of signaling. This means a source process will send a signal
(recognized by number) and the destination process will handle it accordingly.
7. Sockets –This method is mostly used to communicate over a network
between a client and a server. It allows for a standard connection which is
computer and OS independent.
Important System Calls Used in OS for Process Generation
 wait()
In some systems, a process needs to wait for another process to complete its
execution. This type of situation occurs when a parent process creates a child
process, and the execution of the parent process remains suspended until its
child process executes.
The suspension of the parent process automatically occurs with a wait() system
call. When the child process ends execution, the control moves back to the
parent process.
 fork()
Processes use this system call to create processes that are a copy of themselves.
With the help of this system Call parent process creates a child process, and the
execution of the parent process will be suspended till the child process
executes.
 exec()
This system call runs when an executable file in the context of an already
running process that replaces the older executable file. However, the original
process identifier remains as a new process is not built, but stack, data, head,
data, etc. are replaced by the new process.
 kill():
The kill() system call is used by OS to send a termination signal to a process
that urges the process to exit. However, a kill system call does not necessarily
mean killing the process and can have various meanings.
 exit():
The exit() system call is used to terminate program execution. Specially in the
multi-threaded environment, this call defines that the thread execution is
complete. The OS reclaims resources that were used by the process after the use
of exit() system call.

You might also like