0% found this document useful (0 votes)
3 views3 pages

DC - Exp 1

The document outlines an experiment performed by Taha Murade on Inter-process Communication (IPC), detailing its importance and various types such as message passing and shared memory. It includes a code example demonstrating IPC using Python's multiprocessing module, where a sender process sends a message to a receiver process through a queue. The conclusion confirms the successful execution of IPC.

Uploaded by

tahamurade01
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)
3 views3 pages

DC - Exp 1

The document outlines an experiment performed by Taha Murade on Inter-process Communication (IPC), detailing its importance and various types such as message passing and shared memory. It includes a code example demonstrating IPC using Python's multiprocessing module, where a sender process sends a message to a receiver process through a queue. The conclusion confirms the successful execution of IPC.

Uploaded by

tahamurade01
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/ 3

Experiment 1

Name of the Student: - Taha Murade


Roll No. : 74
Date of Practical Performed: - Staff Signature with Date & Marks :

Aim: Write a program to perform Inter-process communication


Theory:
Inter-process Communication (IPC) refers to the mechanisms that allow processes (programs in
execution) to communicate with each other and synchronize their actions. In a distributed system
or multiprocessing environment, different processes often need to exchange data or signals to
coordinate their tasks or share resources. IPC is crucial for ensuring that processes can work
together efficiently and safely.
Types of Inter-Process Communication (IPC):

1. Message Passing: Processes communicate by sending and receiving messages. The


message can be passed through direct communication (point-to-point) or indirect
communication (via a message queue).
2. Shared Memory: Multiple processes access the same region of memory for
communication. One process writes to the memory, and other processes read from it.
3. Message-Oriented Middleware (MOM): Middleware that allows processes to send
messages asynchronously through a messaging system. MOM provides reliable, scalable,
and decoupled communication.
4. Remote Procedure Call (RPC): A protocol that allows a program to execute code on a
remote machine as if it were a local function call. This is often used for distributed systems
where processes on different machines need to interact.
5. Distributed Shared Memory (DSM): A system where multiple machines or processes
share the same memory space, making it appear as though they have a global memory. It
allows processes to communicate as if they were sharing memory.

Example Use Cases for IPC:

● Client-Server Applications: Clients may communicate with servers using sockets, RPCs,
or message queues.
● Multi-threaded Programs: Different threads within a process might use shared memory
or semaphores to communicate.
● Distributed Systems: Different nodes in a distributed system might use sockets, message
queues, or MOM to exchange information.
● Real-Time Systems: Using signals or semaphores for process synchronization in time-
sensitive applications.
Code:
# -*- coding: utf-8 -*-
"""
Created on Tue Jan 7 10:24:01 2025
@author: student
"""
import multiprocessing
import time

# Define the sender function that will put messages into the queue
def sender(q):
# Simulate some work
time.sleep(2)
message = "Hello, introduction to distributed computing "
print(f"Sender is sending: {message}")
q.put(message) # Put the message into the queue

# Define the receiver function that will get messages from the queue
def receiver(q):
# Receive the message from the queue
message = q.get()
print(f"Receiver received: {message}")

# Main function to run the processes


def run_ipc():
# Create a queue for communication between processes
q = multiprocessing.Queue()
# Create sender and receiver processes
sender_process = multiprocessing.Process(target=sender, args=(q,))
receiver_process = multiprocessing.Process(target=receiver, args=(q,))
# Start both processes
sender_process.start()
receiver_process.start()
# Wait for both processes to finish
sender_process.join()
receiver_process.join()
#print("IPC between processes completed.")
# Execute the IPC function
if __name__ == "__main__":
run_ipc()
#run_ipc()
Output:

Conclusion: Hence, we have successfully performed Inter-process communication

Abbreviation Meaning

CC coordinating conjunction

CD cardinal digit

DT determiner

EX existential there

FW foreign word

IN preposition/subordinating conjunction

JJ This NLTK POS Tag is an adjective (large)

JJR adjective, comparative (larger)

JJS adjective, superlative (largest)

LS list market

MD modal (could, will)

NN noun, singular (cat, tree)

You might also like