EmbLogic's Blog

PROJECT 3 : A Linux System Programming using IPC.

A Linux System Programming using IPC.

Many times for any client-server set-up to work efficiently, there arises a problem to share data or resources among various processes that are running.
IPC involves many communication and synchronization techniques used to achieve this, within a network or may be over the network to send/recieve data between two or more running processes.(at transport layer using SOCKETS)

This project is implemented to achieve inter-process communication seemlessly, using various communication and synchronization techniques including PIPEs, FIFOs, MESSAGE QUEUES, SHARED MEMORY, SEMAPHORE and SIGNALS.

General Idea:
There may be 1 server and many requesting clients and a few processing clients.
Many requesting clients may send their requests to the server at any point of time and server maintains a database so as to recognize the request and invoke appropriate processing client to calculate the result of the query.
Also server must send the results of the requests to the associated requesting clients without any loss of data.

1.
In my first attempt i implemented 1 server that itself invokes 3 requesting clients using PIPEs and recieves various requests from them.
After having the requests it invokes appropriate processing clients using another set of 3 processing PIPEs to process the requests and calculate respective results to be sent back to appropriate requesting clients.

Problems Encountered:
1) There was a problem in synchronizing the mechanism.
2) Block on read
3) Block on write.

Remedy:
I implemented signals to synchronize the mechanism.

2.
Then to make requesting clients independent of the server i implemented FIFOs to take requests from various requesting clients and to provide them with appropriate results.
I used 1 requesting FIFO to get all the requests from the requesting clients.
After decoding the request server invokes appropriate processing clients to get the result using PIPEs.
Then the server sends the results to the requesting clients by another FIFO.
The requesting clients also sent their PIDs so as to be signaled by the server.

Problems encountered:
1)Block on open.
2)Block on read.
3)Block on write.
4)Synchronization.

Remedy:
i implemented signals to sync the mechanism.

3.
Then i implemented MESSAGE QUEUE to get the requests from the requesting clients and everything else was same.
The requirement for synchronization was appreciately decreased as there was no need of the processes to be present all the time as was in the case of FIFOs.
The reader or the writer can anytime access the MESSAGE QUEUE to read or write the data along with their PIDs.

Problems encountered in MESSAGE QUEUEs:
1) Max size limited by data chunk of message queue.
2) Max size of queue is also system limited..
Remedy:
I implemented SHARED MEMORY and SEMAPHORES to achieve synchronization.

4.
Now i modified the above architecture and used SHARED MEMORY instead of resulting FIFOto achieve synchronization. Still sync was not apprecisble.
Problem encountered:
Synchronization while sending the results back to the requesting clients was not proper.

Remedy:
Use semaphores.

5.
Finally i implemented each of the above mentioned techniques to implement the project.
The requesting clients used MESSAGE QUEUE to send the requests to the server.
Server, after analysing the requests, invoked appropriate processing client to calculate the result.
Then server used SHARED MEMORY to sent results back to the requesting clients.
SEMAPHORES were implemented to synchronize shared memory access by various requesting clients.

Submitted By:
HARPREET SINGH
Batch no.:
20.02.36

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>