DOC PREVIEW
UMass Amherst CS 677 - RPCs

This preview shows page 1-2-3 out of 10 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 10 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 10 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 10 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 10 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

CS677: Distributed OSComputer ScienceLecture 4, page 1Last Class: RPCs• RPCs make distributed computations look like localcomputations• Issues:– Parameter passing– Binding– Failure handlingCS677: Distributed OSComputer ScienceLecture 4, page 2Today:• Case Study: Sun RPC• Lightweight RPCs• Remote Method Invocation (RMI)– Design issuesCS677: Distributed OSComputer ScienceLecture 4, page 3Case Study: SUNRPC• One of the most widely used RPC systems• Developed for use with NFS• Built on top of UDP or TCP– TCP: stream is divided into records– UDP: max packet size < 8912 bytes– UDP: timeout plus limited number of retransmissions– TCP: return error if connection is terminated by server• Multiple arguments marshaled into a single structure• At-least-once semantics if reply received, at-least-zero semanticsif no reply. With UDP tries at-most-once• Use SUN’s eXternal Data Representation (XDR)– Big endian order for 32 bit integers, handle arbitrarily large data structuresCS677: Distributed OSComputer ScienceLecture 4, page 4Binder: Port Mapper•Server start-up: create port•Server stub calls svc_register toregister prog. #, version # withlocal port mapper•Port mapper stores prog #,version #, and port•Client start-up: call clnt_createto locate server port•Upon return, client can callprocedures at the serverCS677: Distributed OSComputer ScienceLecture 4, page 5Rpcgen: generating stubs• Q_xdr.c: do XDR conversion• Detailed example: later in this courseCS677: Distributed OSComputer ScienceLecture 4, page 6Lightweight RPCs• Many RPCs occur between client and server on samemachine– Need to optimize RPCs for this special case => use alightweight RPC mechanism (LRPC)• Server S exports interface to remote procedures• Client C on same machine imports interface• OS kernel creates data structures including an argumentstack shared between S and CCS677: Distributed OSComputer ScienceLecture 4, page 7Lightweight RPCs• RPC execution– Push arguments onto stack– Trap to kernel– Kernel changes mem map of client to server address space– Client thread executes procedure (OS upcall)– Thread traps to kernel upon completion– Kernel changes the address space back and returns control toclient• Called “doors” in SolarisCS677: Distributed OSComputer ScienceLecture 4, page 8Doors• Which RPC to use? - run-time bit allows stub to choose betweenLRPC and RPCCS677: Distributed OSComputer ScienceLecture 4, page 9Other RPC Models• Asynchronous RPC– Request-reply behavior often not needed– Server can reply as soon as request is received and execute procedure later• Deferred-synchronous RPC– Use two asynchronous RPCs– Client needs a reply but can’t wait for it; server sends reply via anotherasynchronous RPC• One-way RPC– Client does not even wait for an ACK from the server– Limitation: reliability not guaranteed (Client does not know if procedurewas executed by the server).CS677: Distributed OSComputer ScienceLecture 4, page 10Asynchronous RPCa) The interconnection between client and server in a traditional RPCb) The interaction using asynchronous RPC2-12CS677: Distributed OSComputer ScienceLecture 4, page 11 Deferred Synchronous RPC• A client and server interacting through two asynchronous RPCs2-13CS677: Distributed OSComputer ScienceLecture 4, page 12Remote Method Invocation (RMI)• RPCs applied to objects, i.e., instances of a class– Class: object-oriented abstraction; module with data andoperations– Separation between interface and implementation– Interface resides on one machine, implementation on another• RMIs support system-wide object references– Parameters can be object referencesCS677: Distributed OSComputer ScienceLecture 4, page 13Distributed Objects• When a client binds to a distributed object, load the interface(“proxy”) into client address space– Proxy analogous to stubs• Server stub is referred to as a skeletonCS677: Distributed OSComputer ScienceLecture 4, page 14Proxies and Skeletons• Proxy: client stub– Maintains server ID, endpoint, object ID– Sets up and tears down connection with the server– [Java:] does serialization of local object parameters– In practice, can be downloaded/constructed on the fly (whycan’t this be done for RPCs in general?)• Skeleton: server stub– Does deserialization and passes parameters to server and sendsresult to proxyCS677: Distributed OSComputer ScienceLecture 4, page 15Binding a Client to an Objecta) (a) Example with implicit binding using only global referencesb) (b) Example with explicit binding using global and local referencesDistr_object* obj_ref; //Declare a systemwide object referenceobj_ref = …; // Initialize the reference to a distributed objectobj_ref-> do_something(); // Implicitly bind and invoke a method(a)Distr_object objPref; //Declare a systemwide object referenceLocal_object* obj_ptr; //Declare a pointer to local objectsobj_ref = …; //Initialize the reference to a distributed objectobj_ptr = bind(obj_ref); //Explicitly bind and obtain a pointer to the local proxyobj_ptr -> do_something(); //Invoke a method on the local proxy(b)CS677: Distributed OSComputer ScienceLecture 4, page 16Parameter Passing• Less restrictive than RPCs.– Supports system-wide object references– [Java] pass local objects by value, pass remote objects by referenceCS677: Distributed OSComputer ScienceLecture 4, page 17DCE Distributed-Object Modela) Distributed dynamic objects in DCE.b) Distributed named objectsCS677: Distributed OSComputer ScienceLecture 4, page 18Java RMI• Server– Defines interface and implements interface methods– Server program• Creates server object and registers object with “remoteobject” registry• Client– Looks up server in remote object registry– Uses normal method call syntax for remote methods• Java tools– Rmiregistry: server-side name server– Rmic: uses server interface to create client and server stubsCS677: Distributed OSComputer ScienceLecture 4, page 19Java RMI and Synchronization• Java supports Monitors: synchronized objects– Serializes accesses to objects– How does this work for remote objects?• Options: block at the client or the server• Block at server– Can synchronize across multiple proxies– Problem: what if the client crashes while blocked?• Block at proxy– Need to synchronize clients at different machines– Explicit distributed locking necessary• Java


View Full Document

UMass Amherst CS 677 - RPCs

Download RPCs
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view RPCs and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view RPCs 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?