Processes frequently need to communicate with other processes. For example, in a shell pipeline, the output of the first process must be passed to the second process, and so on down the line. Thus there is a need for communication between processes, preferably in a well-structured way not using interrupts.
In the scenario of inter-process communication, there are three issues as follows:
- How one process can pass information to another?
- Ensure two or more processes do not get into each other’s way when engaging in critical activities.
- Proper sequencing of operations when dependencies are present among the processes.
Inter-Process Communication in Operating System
Processes that comprise a concurrent system yet run in separate address spaces, sharing no data, still need access to common information in order to work together or compete for resources; that is, IPC is also required for systems of processes with no shared memory. Two approaches to sharing information are as follows:
- Data is passed from process to process; an example of this style of process cooperation is a pipeline of processes.
- The common information is managed by a process. In this case, the managing process will carry out operations on the data it encapsulates on request from other processes. This is called the client–server model.
One of the simplest forms of cross-address-space IPC is a pipe or synchronized byte stream: one process can send bytes in an unstructured stream into the pipe, and another can read bytes from the pipe. If an attempt is made to read more bytes than have been written into the pipe, the reading process is blocked until more bytes are available. Note that this method conveys no information about the structure of the byte stream nor of the data types that are being transmitted between the processes. The applications that use the mechanism can, of course, interpret the byte stream as structured, typed data.
Another form of cross-address-space IPC, message passing, is more akin to transferring information in the form of typed arguments on a procedure call or method invocation. A message is constructed with a header indicating the destination of the information and a body containing the arguments.
A pipe is an example of connection-oriented communication between two processes; once the pipe is set up any number of writes and reads can be made to it.
Message passing is an example of connectionless communication; each message needs to be addressed to its intended recipient.
The ipcs retrieve information for IPC, and there are different categories of IPCs, including:
- Semaphores: It is responsible for synchronizing and coordinating processes’ access to shared resources.
- Message Queue: It lists the memory segments used by processes to store and retrieve data.
- Shared Memory: It is used by processes to exchange values.
- Pipes: Through pipes, various processes communicate and exchange messages.
You can use different options with the ipcs command to extract various details. We will analyze each of the options using examples.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.