CS 153 Design of Operating Systems Spring 2015 Lecture 23: Inter-Process Communication (IPC) and Remote Procedure Call (RPC)

Slides:



Advertisements
Similar presentations
Message Passing Vs Distributed Objects
Advertisements

CSE 486/586 Distributed Systems Remote Procedure Call
RPC Robert Grimm New York University Remote Procedure Calls.
Remote Procedure Call (RPC)
Remote Procedure Call Design issues Implementation RPC programming
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Emery Berger University of Massachusetts Amherst Operating Systems CMPSCI 377 Lecture.
Tam Vu Remote Procedure Call CISC 879 – Spring 03 Tam Vu March 06, 03.
Remote Procedure CallCS-4513, D-Term Remote Procedure Call CS-4513 Distributed Computing Systems (Slides include materials from Operating System.
L-7 RPC 1. Last Lecture Important Lessons - Naming Naming is a powerful tool in system design  A layer of indirection can solve many problems Name+context.
CS490T Advanced Tablet Platform Applications Network Programming Evolution.
CS3771 Today: network programming with sockets  Previous class: network structures, protocols  Next: network programming Sockets (low-level API) TODAY!
OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 5: Distributed Objects.
Remote Procedure Calls. 2 Announcements Prelim II coming up in one week: –Thursday, April 26 th, 7:30—9:00pm, 1½ hour exam –101 Phillips –Closed book,
02/02/2004CSCI 315 Operating Systems Design1 Interprocesses Communication Notice: The slides for this lecture have been largely based on those accompanying.
Communication in Distributed Systems –Part 2
02/01/2010CSCI 315 Operating Systems Design1 Interprocess Communication Notice: The slides for this lecture have been largely based on those accompanying.
EEC-681/781 Distributed Computing Systems Lecture 4 Wenbing Zhao Department of Electrical and Computer Engineering Cleveland State University
Remote Procedure Calls. 2 Client/Server Paradigm Common model for structuring distributed computations A server is a program (or collection of programs)
NFS. The Sun Network File System (NFS) An implementation and a specification of a software system for accessing remote files across LANs. The implementation.
Distributed Systems Lecture # 3. Administrivia Projects –Design and Implement a distributed file system Paper Discussions –Discuss papers as case studies.
CSE 486/586, Spring 2013 CSE 486/586 Distributed Systems Remote Procedure Call Steve Ko Computer Sciences and Engineering University at Buffalo.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED SYSTEMS.
Chapter 9 Message Passing Copyright © Operating Systems, by Dhananjay Dhamdhere Copyright © Operating Systems, by Dhananjay Dhamdhere2 Introduction.
Networked File System CS Introduction to Operating Systems.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 12 Communicating over.
Distributed Systems. Interprocess Communication (IPC) Processes are either independent or cooperating – Threads provide a gray area – Cooperating processes.
COSC 3407: Operating Systems
Remote Procedure CallCS-502 Fall Remote Procedure Call CS-502, Operating Systems Fall 2007 (Slides include materials from Operating System Concepts,
CSE 486/586 CSE 486/586 Distributed Systems Remote Procedure Call Steve Ko Computer Sciences and Engineering University at Buffalo.
1 Chapter 2. Communication. STEM-PNU 2 Layered Protocol TCP/IP : de facto standard Our Major Concern Not always 7-layered Protocol But some other protocols.
Remote Procedure Call Andrew Whitaker CSE451. Remote Procedure Call RPC exposes a programming interface across machines: interface PriceService { Price.
CS 390- Unix Programming Environment CS 390 Unix Programming Environment Topics to be covered: Distributed Computing Fundamentals.
1 Lecture 5 (part2) : “Interprocess communication” n reasons for process cooperation n types of message passing n direct and indirect message passing n.
 Remote Procedure Call (RPC) is a high-level model for client-sever communication.  It provides the programmers with a familiar mechanism for building.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved RPC Tanenbaum.
IT 344: Operating Systems Winter 2008 Module 19 Networking & Remote Procedure Call (RPC) Chia-Chi Teng CTB 265.
CSE 451: Operating Systems Winter 2015 Module 22 Remote Procedure Call (RPC) Mark Zbikowski Allen Center 476 © 2013 Gribble, Lazowska,
Distributed Computing A Programmer’s Perspective.
Hwajung Lee.  Interprocess Communication (IPC) is at the heart of distributed computing.  Processes and Threads  Process is the execution of a program.
Remote Procedure CallCS-502 Fall Remote Procedure Call (continued) CS-502, Operating Systems Fall 2007 (Slides include materials from Operating System.
Mark Stanovich Operating Systems COP Primitives to Build Distributed Applications send and receive Used to synchronize cooperating processes running.
1 Chapter 38 RPC and Middleware. 2 Middleware  Tools to help programmers  Makes client-server programming  Easier  Faster  Makes resulting software.
Lecture 4 Mechanisms & Kernel for NOSs. Mechanisms for Network Operating Systems  Network operating systems provide three basic mechanisms that support.
Web Services An Introduction Copyright © Curt Hill.
Computer Science Lecture 3, page 1 CS677: Distributed OS Last Class: Communication in Distributed Systems Structured or unstructured? Addressing? Blocking/non-blocking?
Implementing Remote Procedure Call Landon Cox February 12, 2016.
© Oxford University Press 2011 DISTRIBUTED COMPUTING Sunita Mahajan Sunita Mahajan, Principal, Institute of Computer Science, MET League of Colleges, Mumbai.
Distributed Systems: Distributed File Systems Ghada Ahmed, PhD. Assistant Prof., Computer Science Dept. Web:
Computer Science Lecture 4, page 1 CS677: Distributed OS Last Class: RPCs RPCs make distributed computations look like local computations Issues: –Parameter.
Topic 4: Distributed Objects Dr. Ayman Srour Faculty of Applied Engineering and Urban Planning University of Palestine.
Object Interaction: RMI and RPC 1. Overview 2 Distributed applications programming - distributed objects model - RMI, invocation semantics - RPC Products.
CSE 486/586 Distributed Systems Remote Procedure Call
CSE 451: Operating Systems Winter 2006 Module 20 Remote Procedure Call (RPC) Ed Lazowska Allen Center
DISTRIBUTED COMPUTING
Lecture 4: RPC Remote Procedure Call Coulouris et al: Chapter 5
CSE 451: Operating Systems Autumn 2003 Lecture 16 RPC
CSE 451: Operating Systems Winter 2007 Module 20 Remote Procedure Call (RPC) Ed Lazowska Allen Center
Lecture 4: RPC Remote Procedure Call CDK: Chapter 5
CSE 451: Operating Systems Winter 2004 Module 19 Remote Procedure Call (RPC) Ed Lazowska Allen Center
CSE 451: Operating Systems Spring 2012 Module 22 Remote Procedure Call (RPC) Ed Lazowska Allen Center
CSE 451: Operating Systems Autumn 2009 Module 21 Remote Procedure Call (RPC) Ed Lazowska Allen Center
Remote Procedure Call Hank Levy 1.
Chapter 15: File System Internals
Remote Procedure Call Hank Levy 1.
CSE 451: Operating Systems Autumn 2010 Module 21 Remote Procedure Call (RPC) Ed Lazowska Allen Center
Lecture 7: RPC (exercises/questions)
CSE 451: Operating Systems Winter 2003 Lecture 16 RPC
Remote Procedure Call Hank Levy 1.
Last Class: Communication in Distributed Systems
CSE 451: Operating Systems Messaging and Remote Procedure Call (RPC)
Presentation transcript:

CS 153 Design of Operating Systems Spring 2015 Lecture 23: Inter-Process Communication (IPC) and Remote Procedure Call (RPC)

Reminder l Project 2 due today 2

3 Inter-Process Communication l Exchange of data between two or more separate, independent processes. l Operating systems provide facilities/resources for inter- process communications (IPC), such as message queues, semaphores, and shared memory. l Distributed computing systems make use of these facilities/resources to provide higher level of abstraction. (e.g., send and receive) l Distributed computing requires information to be exchanged among independent processes.

Inter-Process Communication l Two main types u Message queues (heavy kernel involvement) u Shared memory (discussed earlier, minimal kernel involvement) 4

Message Queues 5 P1 P2 Kernel Message Queue msg Data copy msg Data copyUser

Message Queues Two basic operations: send(message) and receive(message) u message contents can be anything mutually comprehensible »data, remote procedure calls, executable code etc. u usually contains standard fields »destination process ID, sending process ID for any reply »message length »data type, data etc. l UNIX u System V Message Queues u UNIX domain socket, local TCP/UDP socket 6

l Once page table mapping setup, no syscall or additional copying necessary 7 Shared Memory Page frame P2’s Page Table Physical Memory Page frame P1’s Page Table

Network Communication l By in large similar to lPC in terms of the interface l send(message) and receive(message) u message contents can be anything mutually comprehensible »data, remote procedure calls, executable code etc. u usually contains standard fields »destination server IP, sending client IP »message length »data type, data etc. 8

Client-Server Communication 1.Client connects to the server (locates it and establishes a connection to it) 2.Client sends a request to the server 3.Server performs some action 4.Server sends a response back 9 Request Response ClientServer

OS Support for Network l OS includes implementations of network protocols u For example: TCP, UDP, ICMP, etc. l How should applications use these protocols for network communication? u Open network connection to the server u Hand-code messages to send requests and receive responses u For example, request/response for weather service: »(Date: 01/27/2014, City: Riverside, State: CA) »(Temperature: 70, Chance of rain: 20%) 10

11 Why is RPC Interesting? l Remote Procedure Call (RPC) is the most common means for remote communication l It is used both by operating systems and applications u NFS is implemented as a set of RPCs u DCOM, CORBA, Java RMI, etc., are all basically just RPC l Someday (soon?) you will most likely have to write an application that uses remote communication (or you already have) u You will most likely use some form of RPC for that remote communication u So it’s good to know how all this RPC stuff works

12 Clients and Servers l The prevalent model for structuring distributed computation is the client/server paradigm l A server is a program (or collection of programs) that provide a service (file server, name service, etc.) u The server may exist on one or more nodes u Often the node is called the server, too, which is confusing l A client is a program that uses the service u A client first binds to the server (locates it and establishes a connection to it) u A client then sends requests, with data, to perform actions, and the servers sends responses, also with data

13 Messages: A Bad Abstraction l Hand-coding messages gets tiresome u Need to worry about message formats u Have to pack and unpack data from messages u Servers have to decode and dispatch messages to handlers u Messages are often asynchronous l Messages are not a very natural programming model (still heavily used nevertheless) u Think about web browsing

14 Procedure Calls l Procedure calls are a more natural way to communicate u Every language supports them u Semantics are well-defined and understood u Natural for programmers to use l Idea: Have servers export a set of procedures that can be called by client programs u For example: GetWeather(Date, City, State) u Similar to module interfaces, class definitions, etc. l Clients just do a procedure call as if they were directly linked with the server u Under the covers, the procedure call is converted into a message exchange with the server

15 Remote Procedure Calls l So, we would like to use procedure call as a model for distributed (remote) communication l Remote Procedure Call (RPC) is used both by operating systems and applications u NFS is implemented as a set of RPCs u DCOM, CORBA, Java RMI, etc., are all basically just RPC l Lots of issues u How do we make this invisible to the programmer? u What are the semantics of parameter passing? u How do we (locate, connect) to servers? u How do we support heterogeneity (OS, arch, language)? u How do we make it perform well?

16 RPC Model l A server defines the server’s interface using an interface definition language (IDL) u The IDL specifies the names, parameters, and types for all client-callable server procedures l A stub compiler reads the IDL and produces two stub procedures for each server procedure (client and server) u The server programmer implements the server procedures and links them with the server-side stubs u The client programmer implements the client program and links it with the client-side stubs u The stubs are responsible for managing all details of the remote communication between client and server

17 RPC Example Server Interface: int Add(int x, int y); Client Program: … sum = server->Add(3,4); … Server Program: int Add(int x, int, y) { return x + y; } l If the server were just a library, then Add would just be a procedure call

18 RPC Example: Call Client Program: sum = server->Add(3,4); Server Program: int Add(int x, int, y) {} Client Stub: Int Add(int x, int y) { Alloc message buffer; Mark as “Add” call; Store x, y into buffer; Send message; } RPC Runtime: Send message to server; Server Stub: Add_Stub(Message) { Remove x, y from buffer r = Add(x, y); } RPC Runtime: Receive message; Dispatch, call Add_Stub;

19 RPC Example: Return Client Program: sum = server->Add(3,4); Server Program: int Add(int x, int, y) {} Client Stub: Int Add(int x, int y) { Create, send message; Remove r from reply; return r; } RPC Runtime: Return reply to stub; Server Stub: Add_Stub(Message) { Remove x, y from buffer r = Add(x, y); Store r in buffer; } RPC Runtime: Send reply to client;

20 RPC Summary l RPC is the most common model for communication in distributed applications u “Cloaked” as DCOM, CORBA, Java RMI, etc. u Also used on same node between applications l RPC is language support for distributed programming l RPC relies upon a stub compiler to automatically generate client/server stubs from the IDL server descriptions u These stubs do the marshalling/unmarshalling, message sending/receiving/replying l NFS uses RPC to implement remote file systems u Statelessness makes it easy to implement, but introduces consistency issues

Android IPC and AIDL 21 App Camera Service 1. Request taking a picture 3. Return the picture 2. Take a picture by talking to driver Why do we introduce a service process acting as a proxy to access the driver?

22 Android IPC and AIDL Example Server Interface: Pic takePic(); Client Process: … pic = server->takePic(); … Server Process: Pic takePic() { // talk to driver return pic; } l Why do we need this on a single host?

23 Network File System l We have talked about file systems and RPC l We’ll now look at a file system that uses RPC l Network File System (NFS) u Protocol for remote access to a file system »Does not implement a file system per se »Remote access is transparent to applications u File system, OS, and architecture independent »Originally developed by Sun »Although Unix-y in flavor, explicit goal to work beyond Unix u Client/server architecture »Local file system requests are forwarded to a remote server »These requests are implemented as RPCs

Architecture 24

25 Mounting l Before a client can access files on a server, the client must mount the file system on the server u The file system is mounted on an empty local directory u Same way that local file systems are attached u Can depend on OS (e.g., Unix dirs vs NT drive letters) u E.g., Lab machines mount home directory from NFS servers u “mount backend:/home/csgrads /home/csgrads” l Servers maintain ACLs of clients that can mount their directories u When mount succeeds, server returns a file handle u Clients use this file handle as a capability to do file operations l Mounts can be cascaded u Can mount a remote file system on a remote file system

26 NFS Protocol l The NFS protocol defines a set of operations that a server must support u Reading and writing files u Accessing file attributes u Searching for a file within a directory u Reading a set of directory links u Manipulating links and directories l These operations are implemented as RPCs u Usually by daemon processes (e.g., nfsd) u A local operation is transformed into an RPC to a server u Server performs operation on its own file system and returns

27 Statelessness l Note that NFS has no open or close operations l NFS is stateless u An NFS server does not keep track of which clients have mounted its file systems or are accessing its files u Each RPC has to specify all information in a request »Operation, FS handle, file id, offset in file, sequence # »How is this good or bad? l Robust u No reconciliation needs to be done on a server crash/reboot u Clients detect server reboot, continue to issue requests l Writes must be synchronous to disk, though u Clients assume that a write is persistent on return u Servers cannot cache writes

28 Consistency l Since NFS is stateless, consistency is tough u What do we mean by consistency? u NFS can be (mostly) consistent, but limits performance u NFS assumes that if you want consistency, applications will use higher-level mechanisms to guarantee it l Writes are supposed to be atomic u But performed in multiple RPCs (larger than a network packet) u Simultaneous writes from clients can interleave RPCs (bad) l Server caching u Can cache for reads, but we saw that it cannot cache writes

29 Consistency (2) l Client caching can lead to consistency problems u Caching a write on client A will not be seen by other clients u Cached writes by clients A and B are unordered at server u Since sharing is rare, though, NFS clients usually do cache l NFS statelessness is both its key to success and its Achilles’ heel u NFS is straightforward to implement and reason about u But limitations on caching can severely limit performance »Dozens of network file system designs and implementations that perform much better than NFS u But note that it is still the most widely used remote file system protocol and implementation