Remote Procedure Call Andy Wang Operating Systems COP

  • Slides: 12
Download presentation
Remote Procedure Call Andy Wang Operating Systems COP 4610 / CGS 5765

Remote Procedure Call Andy Wang Operating Systems COP 4610 / CGS 5765

Primitives to Build Distributed Applications n send and receive Used to synchronize cooperating processes

Primitives to Build Distributed Applications n send and receive Used to synchronize cooperating processes running on different machines n Communicate through mailboxes (ports) n n n Temporary holding areas for messages Atomic operations n send/receive the entire message or nothing

More on send and receive n To put a message to the network n

More on send and receive n To put a message to the network n send(message, destination_mbox) n receive(buffer, mbox) n n Waits until a message arrives Copies the message into a given buffer

Remote Procedure Call (RPC) n Allows you to invoke a procedure on either a

Remote Procedure Call (RPC) n Allows you to invoke a procedure on either a local or remote machine n Client n n Remote. Machine Say(“Meow”); Server n Machine Say(“Meow”); n Implemented on top of two-way messaging

RPC Illustrated Client (caller) call Server (callee) reply Client stub call Server stub OS

RPC Illustrated Client (caller) call Server (callee) reply Client stub call Server stub OS or Network

Procedure Stubs n Provide the invocation interface programmers n e. g. foo(int a) n

Procedure Stubs n Provide the invocation interface programmers n e. g. foo(int a) n Client stub n Build messages (a. k. a. marshalling) n Send messages n Wait for response n Unpack reply n Return result

Server Stub n Create N threads to wait for requests n Loop n Wait

Server Stub n Create N threads to wait for requests n Loop n Wait for command n Decode and unpack request parameters (unmarshalling) n Call procedure n Build replay message with results n Send reply

RPC vs. Procedure Call n From the programmer’s viewpoint n Similar semantics n Pointers

RPC vs. Procedure Call n From the programmer’s viewpoint n Similar semantics n Pointers are instantiated before transmission n Data structures pointed by the pointer are copied n Processes running on the remote machine is in a different address space

Implementation Issues n Stubs are automatically generated n Need to have a well-known port

Implementation Issues n Stubs are automatically generated n Need to have a well-known port to talk to servers n Server can upgrade the implementation without recompiling client applications

Interprocess Communication n RPC is just another way to communicate between processes n Example

Interprocess Communication n RPC is just another way to communicate between processes n Example uses n Microkernel operating systems n n Portions of an OS are implemented at the user level to minimize the kernel-level code Object linking and embedding (OLE) n Mix-and-match applications

Using RPC for IPC + Fault isolation: bugs are unlikely to propagate across different

Using RPC for IPC + Fault isolation: bugs are unlikely to propagate across different address spaces + Modularity: independent component upgrades + Location transparency: a service can be provided from local or remote machines

Using RPC for IPC - Poor performance - A wide range of failure modes

Using RPC for IPC - Poor performance - A wide range of failure modes A user-level bug can cause a process failure n A kernel-level bug can cause multiple processes to fail n A network failure, server failure, or an earthquake can cause multiple machines to fail n