Multiprocess Communication Flashcards

1
Q

What is Interprocess Communication (IPC)?

A

IPC allows processes to manage shared data. This is achieved through:
○ Message Passing: A way for processes to communicate by sending and receiving messages.
○ Remote Procedure Calls (RPC): A mechanism that allows a process to call a procedure/function located in another process as if it were a local procedure.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
1
Q

What are the two main options for concurrency in operating systems?

A

○Option 1: Processes
■ Apps are built from many communicating processes.
■ Processes communicate through message passing.
■ Processes do not share memory.
■ Pros: If one process crashes, others are unaffected.
■ Cons: High communication overheads and expensive context switching.

○Option 2: Threads
■ Introduces the concept of a thread.
■Multiple threads exist within a single process.
■Threads are similar to processes, but Multiple threads within the same process share an address space.
■ Pros: Communicate through shared address space.
■ Cons: If one thread crashes, the entire process crashes, including other threads.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Where is IPC necessary

A

IPC is needed in scenarios such as:
○ Client-server communication: This involves the exchange of data between a client process and a server process, which might be running on different machines or within the same machine.

○ Communication between cooperating processes: Different processes involved in a larger task might need to communicate and share data to coordinate their activities. An example is the interaction between a listener process and worker processes in a multiprocess web server.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How does message passing work at a high level?

A

○ Message passing uses send and receive primitives.
○ Data is copied from the sender’s address space to the receiver’s address space. This ensures that the receiver cannot modify the original message in the sender’s address space, providing isolation.
○ This is a form of by-value communication, not by reference.
○ The kernel (operating system core) manages the messages.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are the different message passing alternatives and their characteristics?

A

○ Symmetric/Asymmetric Addressing:
■Symmetric: Both sender and receiver specify each other’s process IDs. This form is less common.
■Asymmetric: The sender specifies the receiver’s process ID, but the receiver doesn’t need to specify the sender’s ID. This is more common and flexible.

○Blocking/Nonblocking Operations:
■Blocking Send: The sender waits until the message is delivered (or at least copied to a safe location) before continuing execution.
■Nonblocking Send: The sender continues execution immediately after sending the message. This is the more common approach.
■Blocking Receive: The receiver waits until a message is available. This is the more common form of receiving messages.
■Nonblocking Receive: The receiver checks if a message is available and retrieves it if it is. If not, it continues execution.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is a Remote Procedure Call (RPC)?

A

RPC provides a way to invoke procedures/functions on a remote process/server as if they were local function calls.

○ Client-Side: The client process calls the procedure using a local function-like syntax. The RPC mechanism then handles the communication to send the request to the server.
○ Server-Side: The server process receives the request, executes the procedure, and sends the results back to the client.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How is RPC implemented?

A

RPC is typically implemented using these components:

○ Interface Definition: An interface defines the procedures that a server provides, specifying their names, parameters, and return types. This acts as a contract between the client and the server.
○ Client Stub: This component resides on the client side and acts as a proxy for the remote procedure. When the client calls the procedure, the client stub packs the parameters into a message and sends it to the server.
○ Server Stub: This component resides on the server side and acts as a counterpart to the client stub. The server stub receives the message, unpacks the parameters, calls the actual server-side procedure, and sends the results back to the client stub.
○ Message Passing: Underlying the communication between the client and server stubs is a message passing mechanism.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are the typical message types in RPC and what do they contain?

A

○ Call Message: Sent from the client stub to the server stub. It contains the procedure identifier (which procedure to call), and the arguments or parameters for the procedure.

○ Return Message: Sent from the server stub to the client stub. It contains the return values of the procedure or an error code if the procedure execution failed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the role of stub compilers in RPC?

A

○ Stub compilers are tools designed to automate the generation of client and server stubs. They take an interface definition as input and generate the necessary code for these stubs, greatly simplifying the development process of RPC-based applications.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How can you implement RPC in Linux?

A


The On-Demand Remote Procedure Call (RPC) library in Linux enables procedure calls across networks and can be used for inter-process communication on the same machine.

You’ll need the rpcbind service running. Install it with: sudo apt-get install rpcbind. This service translates RPC program numbers into universal addresses.

Use the rpcgen tool to automatically generate RPC interface modules. It takes source code written in the RPC language (similar to C), compiles it, and produces C language source modules that can then be compiled by a C compiler.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly