remote procedure call andy wang operating systems cop 4610 / cgs 5765

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

Upload: lewis-wells

Post on 20-Jan-2016

214 views

Category:

Documents


0 download

TRANSCRIPT

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

Remote Procedure Call

Andy Wang

Operating Systems

COP 4610 / CGS 5765

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

Primitives to Build Distributed Applications send and receive

Used to synchronize cooperating processes running on different machines

Communicate through mailboxes (ports) Temporary holding areas for messages

Atomic operations send/receive the entire message or nothing

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

More on send and receive

To put a message to the network send(message, destination_mbox) receive(buffer, mbox)

Waits until a message arrives Copies the message into a given buffer

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

Remote Procedure Call (RPC)

Allows you to invoke a procedure on either a local or remote machine Client

RemoteMachineSay(“Meow”); Server

MachineSay(“Meow”);

Implemented on top of two-way messaging

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

RPC Illustrated

Server (callee)Client (caller)

OS or Network

Server stubClient stub

call reply callreply

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

Procedure Stubs

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

Client stub Build messages (a.k.a. marshalling) Send messages Wait for response Unpack reply Return result

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

Server Stub

Create N threads to wait for requests Loop

Wait for command Decode and unpack request parameters

(unmarshalling) Call procedure Build replay message with results Send reply

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

RPC vs. Procedure Call

From the programmer’s viewpoint Similar semantics

Pointers are instantiated before transmission Data structures pointed by the pointer are

copied Processes running on the remote machine is

in a different address space

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

Implementation Issues

Stubs are automatically generated Need to have a well-known port to talk to

servers Server can upgrade the implementation

without recompiling client applications

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

Interprocess Communication

RPC is just another way to communicate between processes

Example uses Microkernel operating systems

Portions of an OS are implemented at the user level to minimize the kernel-level code

Object linking and embedding (OLE) Mix-and-match applications

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

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

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

Using RPC for IPC

- Poor performance

- A wide range of failure modes A user-level bug can cause a process failure A kernel-level bug can cause multiple

processes to fail A network failure, server failure, or an

earthquake can cause multiple machines to fail