Wednesday, 28 August 2013

Explain the term inter-process communication. What are various approaches to achieve the same.

Inter Process Communication:
·        Pipes
·        Fifos (Named Pipes)
·        Message queues
·        Semaphores
·        Shared memory
·        Sockets
·        Communications via Pipes
Pipes:
Once we got our processes to run, we suddenly realize that they cannot communicate. One of the mechanisms that allow related-processes to communicate is the pipe, or the anonymous pipe.
A pipe is a one –way mechanism that allows two related processes to send a byte stream from one of them to the other one.
Named Pipe:
A named pipe is a pipe whose access point is a file kept on the file system.
By opening this file for reading, a process gets access to the reading end of the pipe. By opening the file for writing, the process gets access to the writing end of the pipe.
Message Queues:
A message queues is a queue onto which messages can be placed. A message is composed of a message type and message data.
            A message queue can be either private, or public. If it is private, it can be accessed only by its creating process or child processes of that creator. If its public, it can accessed by any process that knows the queue’s key.
Semaphore:
A semaphore is a resource that contains an integer value and allows processes to synchronize by testing and setting this value in a single atomic operation. This means that the process that tests the value of a semaphore and sets it to a different value, is guaranteed and no other process will interface with the operation in the middle.
Shared Memory:
As we might know, many methods were created in order to let processes communicate. All this communication is done in order to share data. The problem is that all these methods are sequential in nature. We want to allow processes to share data in a random access manner. For this, we will use shared memory that comes to the rescue.

            With shared memory, we declare a given section in the memory as one that will be used simultaneously by several processes. This means that the data found in this memory section will be seen by several processes. This also means that several processes. This also means that several processes might try to alter this memory area at the same time, and thus some method should be used to synchronize their access to this memory area.

No comments:

Post a Comment