Unformatted text preview:

CSE 120 Principles of Operating Systems Fall 2004 Lecture 14 Remote Procedure Call And Network File System Geoffrey M Voelker Why is RPC Interesting z z Remote Procedure Call RPC is the most common means for remote communication It is used both by operating systems and applications z NFS is implemented as a set of RPCs DCOM CORBA Java RMI etc are all basically just RPC Someday soon you will most likely have to write an application that uses remote communication or you already have You will most likely use some form of RPC for that remote communication So it s good to know how all this RPC stuff works More debunking the magic November 22 2004 CSE 120 Lecture 14 Remote Procedure Call 2004 Geoffrey M Voelker 2 1 Clients and Servers z z The prevalent model for structuring distributed computation is the client server paradigm A server is a program or collection of programs that provide a service file server name service etc z The server may exist on one or more nodes Often the node is called the server too which is confusing A client is a program that uses the service A client first binds to the server locates it and establishes a connection to it A client then sends requests with data to perform actions and the servers sends responses also with data November 22 2004 CSE 120 Lecture 14 Remote Procedure Call 2004 Geoffrey M Voelker 3 Messages z z Initially with network programming people hand coded messages to send requests and responses Hand coding messages gets tiresome z Need to worry about message formats Have to pack and unpack data from messages Servers have to decode and dispatch messages to handlers Messages are often asynchronous Messages are not a very natural programming model Could encapsulate messaging into a library Just invoke library routines to send a message Which leads us to RPC November 22 2004 CSE 120 Lecture 14 Remote Procedure Call 2004 Geoffrey M Voelker 4 2 Procedure Calls z Procedure calls are a more natural way to communicate z Idea Have servers export a set of procedures that can be called by client programs z Every language supports them Semantics are well defined and understood Natural for programmers to use Similar to module interfaces class definitions etc Clients just do a procedure call as it they were directly linked with the server Under the covers the procedure call is converted into a message exchange with the server November 22 2004 CSE 120 Lecture 14 Remote Procedure Call 2004 Geoffrey M Voelker 5 Remote Procedure Calls z z So we would like to use procedure call as a model for distributed remote communication Lots of issues How do we make this invisible to the programmer What are the semantics of parameter passing How do we bind locate connect to servers How do we support heterogeneity OS arch language How do we make it perform well November 22 2004 CSE 120 Lecture 14 Remote Procedure Call 2004 Geoffrey M Voelker 6 3 RPC Model z A server defines the server s interface using an interface definition language IDL z The IDL specifies the names parameters and types for all client callable server procedures A stub compiler reads the IDL and produces two stub procedures for each server procedure client and server The server programmer implements the server procedures and links them with the server side stubs The client programmer implements the client program and links it with the client side stubs The stubs are responsible for managing all details of the remote communication between client and server November 22 2004 CSE 120 Lecture 14 Remote Procedure Call 2004 Geoffrey M Voelker 7 RPC Stubs z z z A client side stub is a procedure that looks to the client as if it were a callable server procedure A server side stub looks to the server as if a client called it The client program thinks it is calling the server z The server program thinks it is called by the client z In fact it s calling the client stub In fact it s called by the server stub The stubs send messages to each other to make the RPC happen transparently November 22 2004 CSE 120 Lecture 14 Remote Procedure Call 2004 Geoffrey M Voelker 8 4 RPC Example Server Interface int Add int x int y Client Program Server Program int Add int x int y sum server Add 3 4 z return x y If the server were just a library then Add would just be a procedure call November 22 2004 CSE 120 Lecture 14 Remote Procedure Call 2004 Geoffrey M Voelker 9 RPC Example Call Client Program Server Program sum server Add 3 4 int Add int x int y Client Stub Server Stub Int Add int x int y Add Stub Message Alloc message buffer Remove x y from buffer Mark as Add call r Add x y Store x y into buffer Send message RPC Runtime RPC Runtime Receive message Send message to server Dispatch call Add Stub November 22 2004 CSE 120 Lecture 14 Remote Procedure Call 2004 Geoffrey M Voelker 10 5 RPC Example Return Client Program Server Program sum server Add 3 4 int Add int x int y Client Stub Server Stub Int Add int x int y Add Stub Message Create send message Remove x y from buffer Remove r from reply r Add x y return r Store r in buffer RPC Runtime RPC Runtime Return reply to stub Send reply to client November 22 2004 CSE 120 Lecture 14 Remote Procedure Call 2004 Geoffrey M Voelker 11 RPC Marshalling z z Marshalling is the packing of procedure parameters into a message packet The RPC stubs call type specific procedures to marshal or unmarshal the parameters to a call z The client stub marshals the parameters into a message The server stub unmarshals parameters from the message and uses them to call the server procedure On return The server stub marshals the return parameters The client stub unmarshals return parameters and returns them to the client program November 22 2004 CSE 120 Lecture 14 Remote Procedure Call 2004 Geoffrey M Voelker 12 6 RPC Binding z z Binding is the process of connecting the client to the server The server when it starts up exports its interface z The client before issuing any calls imports the server z Identifies itself to a network name server Tells RPC runtime its alive and ready to accept calls RPC runtime uses the name server to find the location of a server and establish a connection The import and export operations are explicit in the server and client programs Breakdown of transparency November 22 2004 CSE 120 Lecture 14 Remote Procedure Call 2004 Geoffrey M Voelker 13 RPC Transparency z One goal of RPC is to be as transparent as possible z z Make remote procedure calls look like local procedure calls We have


View Full Document

UCSD CSE 120 - Remote Procedure Call And Network File System

Documents in this Course
Threads

Threads

14 pages

Deadlocks

Deadlocks

19 pages

Processes

Processes

14 pages

Paging

Paging

13 pages

Processes

Processes

18 pages

Threads

Threads

29 pages

Security

Security

16 pages

Paging

Paging

13 pages

Processes

Processes

32 pages

Lecture 2

Lecture 2

13 pages

Paging

Paging

8 pages

Threads

Threads

14 pages

Paging

Paging

13 pages

Paging

Paging

26 pages

Paging

Paging

13 pages

Lecture

Lecture

13 pages

Processes

Processes

14 pages

Paging

Paging

13 pages

Security

Security

17 pages

Threads

Threads

15 pages

Processes

Processes

34 pages

Structure

Structure

10 pages

Lecture 3

Lecture 3

13 pages

Lecture 1

Lecture 1

28 pages

Threads

Threads

15 pages

Paging

Paging

30 pages

Load more
Loading Unlocking...
Login

Join to view Remote Procedure Call And Network File System 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 Remote Procedure Call And Network File System 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?