Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 10

Established as per the Section 2(f) of the UGC Act, 1956

Approved by AICTE, COA and BCI, New Delhi

INTER-PROCESS
COMMUNICATION(IPC)
ANIKET MANNA
R 2 0 E F 0 11
A1 SEC
5th Sem
WHAT IS IPC?
Inter-process communication (IPC) is a mechanism that allows processes to
communicate with each other and synchronize their actions

In short, the intercommunication allows a process letting another process know that
some event has occurred.

A process can be of two types: Independent process, Co-operating process

An independent process is not affected by the execution of other processes while a co-
operating process can be affected by other executing processes.
APPROACHES FOR INTER-PROCESS COMMUNICATION

In UNIX, there are two types of inter-process communication (IPC) for the local terminal:

one is the asynchronous signaling of events.


the other is the synchronous transmission of messages between processes.

The synchronous mechanisms, which originate from the UNIX System V, include messages,
shared memory, and semaphores.
There are two fundamental models of inter-process communication:
o

MESSAGE PASSING
Messages Passing Model
In this model two process communicate with each other by passing messages.

• It is easy to implement as compared to shared memory model.

• It is useful to exchange small amount of data.

• This system is much more useful in the distributed environment when two
computers are on the same network and their process want to share the
data
Kernel: The kernel manages the messages in several linked queues. Each queue
has a unique descriptor that can be used to index into an array of message queue
structures
WORKING OF MESSAGE PASSING MODEL
• In this method, processes communicate with each other without using any kind of
shared memory.
 If two processes p1 and p2 want to communicate with each other, they proceed as
follows:
• Establish a communication link (if a link already exists, no need to
establish it again.)
• Using thee send() function it send the necessary message.
Process B, which is monitoring the communication link,uses
The receive() function to pick up the message and perform the
Necessary process based on the receive message
•  A standard message can have two parts: header and body. 
• The header part is used for storing message type, destination id, source id,
message length,and control information,BODY contains main content of the message
Messages Passing Model

Message Passing Model Operations:


1. Send(Message)
2. Receive(Message)

Message mechanism is operated with four system calls:


1. msgget:- message get
2. msgclt:- message control
3. msgsnd:- message send
4. msgcrv:- message receive
SYSTEM CALLS

When a user process wants to communicate with other processes via the messages, it needs to
start from the msgget system call. If it is an existent message queue, msgget returns its descriptor;
if not, msgget creates a new one for the user process and returns its descriptor.

Once the message queue is established, the message-sending process can use the msgsnd
system call to send its messages while the message-receiving process can receive the messages
via the msgrcv system call.

In the msgsnd system call, after passing several condition tests, the kernel allocates the buffer
space, copies the message data from the user space to the buffer, puts the message header that
records the type, size, and location of the message at the end of the queue, and updates the
message queue structure
SYSTEM CALLS

such as increasing the current number of messages on the queue, the current number of bytes on the
queue, and the last PID and last time of msgsnd.

In the msgrcv, if all the tests are successful, the kernel finds the first message on the queue, copies
the message to the user data space, updates the message queue structure, such as reducing the current
number of messages on the queue, the current number of bytes on the queue, and the last PID and last
time of the msgrcv, and frees the buffer space that stored the message.

The msgctl system call can be used to check and set the states of a message descriptor, and remove a
message descriptor (which is just like the close system call in the file system). When necessary, the
permission verification is done by each of msgget, msgsnd, and msgrcv.
THANK YOU

You might also like