COSC 3407: Operating Systems

Slides:



Advertisements
Similar presentations
RPC Robert Grimm New York University Remote Procedure Calls.
Advertisements

Remote Procedure Call (RPC)
Remote Procedure Call Design issues Implementation RPC programming
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.
Tutorials 2 A programmer can use two approaches when designing a distributed application. Describe what are they? Communication-Oriented Design Begin with.
A CHAT CLIENT-SERVER MODULE IN JAVA BY MAHTAB M HUSSAIN MAYANK MOHAN ISE 582 FALL 2003 PROJECT.
CS162 Operating Systems and Systems Programming Lecture 24 Distributed File Systems November 26, 2007 Prof. John Kubiatowicz
CS490T Advanced Tablet Platform Applications Network Programming Evolution.
Sockets  Defined as an “endpoint for communication.”  Concatenation of IP address + port.  Used for server-client communication.  Server waits for.
Learning Objectives Understanding the difference between processes and threads. Understanding process migration and load distribution. Understanding Process.
CS162 Operating Systems and Systems Programming Lecture 23 Network Communication Abstractions / Remote Procedure Call November 20, 2006 Prof. John Kubiatowicz.
Computer Science Lecture 2, page 1 CS677: Distributed OS Last Class: Introduction Distributed Systems – A collection of independent computers that appears.
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,
Communication in Distributed Systems –Part 2
Remote Procedure Calls. 2 Client/Server Paradigm Common model for structuring distributed computations A server is a program (or collection of programs)
Interprocess Communication. Process Concepts Last class.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED SYSTEMS.
CS162 Operating Systems and Systems Programming Lecture 23 Network Communication Abstractions / Remote Procedure Call November 21, 2007 Prof. John Kubiatowicz.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 12 Communicating over.
CSC139 Operating Systems Lecture 23 Remote Procedure Call Adapted from Prof. John Kubiatowicz's lecture notes for CS162
CS 390- Unix Programming Environment CS 390 Unix Programming Environment Topics to be covered: Distributed Computing Fundamentals.
CS 153 Design of Operating Systems Spring 2015 Lecture 23: Inter-Process Communication (IPC) and Remote Procedure Call (RPC)
Problems with Send and Receive Low level –programmer is engaged in I/O –server often not modular –takes 2 calls to get what you want (send, followed by.
Chapter 4: Interprocess Communication‏ Pages
Distributed Systems Concepts and Design Chapter 4.
1 Lecture 5 (part2) : “Interprocess communication” n reasons for process cooperation n types of message passing n direct and indirect message passing n.
CS162 Operating Systems and Systems Programming Lecture 23 Network Communication Abstractions / Distributed Programming November 22, 2010 Prof. John Kubiatowicz.
3.1 Silberschatz, Galvin and Gagne ©2009Operating System Concepts with Java – 8 th Edition Chapter 3: Processes.
 Remote Procedure Call (RPC) is a high-level model for client-sever communication.  It provides the programmers with a familiar mechanism for building.
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 Calls CS587x Lecture Department of Computer Science Iowa State University.
Remote Procedure Call Andy Wang Operating Systems COP 4610 / CGS 5765.
Mark Stanovich Operating Systems COP Primitives to Build Distributed Applications send and receive Used to synchronize cooperating processes running.
Lecture 4 Mechanisms & Kernel for NOSs. Mechanisms for Network Operating Systems  Network operating systems provide three basic mechanisms that support.
© Oxford University Press 2011 DISTRIBUTED COMPUTING Sunita Mahajan Sunita Mahajan, Principal, Institute of Computer Science, MET League of Colleges, Mumbai.
Distributed Computing & Embedded Systems Chapter 4: Remote Method Invocation Dr. Umair Ali Khan.
Lecture 5: RPC (exercises/questions). 26-Jun-16COMP28112 Lecture 52 First Six Steps of RPC TvS: Figure 4-7.
CS162 Operating Systems and Systems Programming Lecture 21 Distributed Decision Making, TCP/IP and Sockets April 13th, 2016 Prof. Anthony D. Joseph
CS162 Operating Systems and Systems Programming Lecture 21 Distributed Decision Making, TCP/IP and Sockets November 9th, 2016 Prof. Anthony D. Joseph.
Last Class: Introduction
IPC and RPC.
CS162 Operating Systems and Systems Programming Lecture 23 Network Communication Abstractions / Remote Procedure Call April 28, 2008 Prof. Anthony D.
CS162 Operating Systems and Systems Programming Lecture 23 Network Communication Abstractions / Remote Procedure Call November 21, 2005 Prof. John Kubiatowicz.
CS162 Operating Systems and Systems Programming Lecture 23 Network Communication Abstractions / Distributed Programming November 25, 2009 Prof. John Kubiatowicz.
CSE 451: Operating Systems Winter 2006 Module 20 Remote Procedure Call (RPC) Ed Lazowska Allen Center
Lecture 4: RPC Remote Procedure Call Coulouris et al: Chapter 5
Sarah Diesburg Operating Systems COP 4610
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
EECE.4810/EECE.5730 Operating Systems
CS162 Operating Systems and Systems Programming Lecture 24 Distributed File Systems November 23, 2005 Prof. John Kubiatowicz
Remote Procedure Call Hank Levy 1.
CS162 Operating Systems and Systems Programming Lecture 23 Remote Procedure Call April 19, 2005 Prof. Anthony D. Joseph
Lecture 6: RPC (exercises/questions)
Remote Procedure Call Hank Levy 1.
CSE 451: Operating Systems Autumn 2010 Module 21 Remote Procedure Call (RPC) Ed Lazowska Allen Center
CS162 Operating Systems and Systems Programming Lecture 24 Network Communication Abstractions / Distributed Programming November 24, 2008 Prof. John Kubiatowicz.
Lecture 6: RPC (exercises/questions)
Lecture 7: RPC (exercises/questions)
CSE 451: Operating Systems Winter 2003 Lecture 16 RPC
Remote Procedure Call Hank Levy 1.
CSE 451: Operating Systems Messaging and Remote Procedure Call (RPC)
Presentation transcript:

COSC 3407: Operating Systems Lecture 22: Interprocess Communication and Remote Procedure Call (RPC)

This lecture… Finish discussion of TCP Messages Remote Procedure Call Send/receive One vs. two-way communication Remote Procedure Call Cross-address space vs. cross-machine communication

Use of TCP: Sockets Socket: an abstraction of a network I/O queue Embodies one side of a communication channel Same interface regardless of location of other end Could be local machine (called “UNIX socket”) or remote machine (called “network socket”) First introduced in 4.2 BSD UNIX: big innovation at time Now most operating systems provide some notion of socket Server Socket socket connection Request Connection new Client

Sockets cont’d Using Sockets for Client-Server (C/C++ interface): On server: set up “server-socket” Create socket, Bind to protocol (TCP), local address, port call listen(): tells server socket to accept incoming requests Perform multiple accept() calls on socket to accept incoming connection request Each successful accept() returns a new socket for a new connection; can pass this off to handler thread On client: Create socket, Bind to protocol (TCP), remote address, port Perform connect() on socket to make connection If connect() successful, have socket connected to server

Socket Example (Java) server: //Makes socket, binds addr/port, calls listen() ServerSocket sock = new ServerSocket(6013); while(true) { Socket client = sock.accept(); PrintWriter pout = new PrintWriter(client.getOutputStream(),true); pout.println(“Here is data sent to client!”); … client.close(); } client: // Makes socket, binds addr/port, calls connect() Socket sock = new Socket(“169.229.60.38”,6018); BufferedReader bin = new BufferedReader( new InputStreamReader(sock.getInputStream)); String line; while ((line = bin.readLine())!=null) System.out.println(line); sock.close();

Send/Receive How do you program a distributed application? Need to synchronize multiple threads, only now running on different machines (no shared memory, can’t use test&set). Key abstraction: send/receive messages. (Note: this abstraction is similar to “read” and “write” of the file I/O interface.) Atomic operations: send/receive – doesn’t require shared memory for synchronizing cooperating threads.

Send/Receive Questions to be answered: Blocking vs. Non-blocking calls Buffered vs. Non-buffered I/O How does addressing work? Mailbox – temporary holding area for messages (ports) Includes both destination location and queue Send(message, mbox) – put message on network, with name of mbox for where it is to go on far end

Send/Receive When can Send return? When receiver gets message? (i.e., acknowledgement received) When message is safely buffered on destination node? Right away, if message is buffered on source node? There are really two questions here: When can the sender be sure that the receiver actually received the message? When can the sender re-use the memory containing the message?

Send/Receive Receive(buffer, mbox) Wait until mbox has message in it, then copy message into buffer, and return. When packet arrives, OS puts message into mbox, wakes up one of the waiters. Note that send and receive are atomic (the OS ensures this abstraction). Never get portion of a message (all or nothing) Two receivers can’t get same message Mailbox provides 1-way communication from T1T2 T1bufferT2 Very similar to producer/consumer Send = V, Receive = P However, can’t tell if sender/receiver is local or not!

Message styles Using send/receive for synchronization: No need for producer/consumer to keep track of space in mailbox – handled by send/receive. Producer: int msg1[1000] while (1) prepare message // make coke send(msg1, mbox) Consumer: int msg2[1000] receive(msg2, mbox) process message // drink coke

Message styles What about two-way communication? Request/response. For instance, “read a file” stored on a remote machine or request a web page from a remote web server. Also called: client-server. Client = requester; server = responder. Server provides “service” (file storage) to the client

Message styles Request/response: Server has to decode command, just as OS has to decode message to find mbox. Client: (requesting the file) char response[1000]; send(“read foo”, mbox1); receive(response, mbox2); Server: char command[1000], answer[1000]; receive(command, mbox1); decode command read file into answer send(answer, mbox2);

Byzantine General’s Problem Lieutenant Attack! General Attack! Attack! Retreat! Retreat! Attack! Malicious! Byazantine General’s Problem (n players): One General n-1 Lieutenants Some number of these (f) can be insane or malicious

Byzantine General’s Problem (cont’d) The commanding general must send an order to his n-1 lieutenants such that: IC1: All loyal lieutenants obey the same order IC2: If the commanding general is loyal, then all loyal lieutenants obey the order he sends Impossibility Results: Cannot solve Byzantine General’s Problem with n=3 because one malicious player can mess up things With f faults, need n > 3f to solve problem General Lieutenant Attack! Retreat!

Byzantine General’s Problem (con’t) Various algorithms exist to solve problem Original algorithm has #messages exponential in n Newer algorithms have message complexity O(n2) One from MIT, for instance (Castro and Liskov, 1999) Use of BFT (Byzantine Fault Tolerance) algorithm Allow multiple machines to make a coordinated decision even if some subset of them (< n/3 ) are malicious Request Distributed Decision

Remote Procedure Call (RPC) Call a procedure on a remote machine. Client calls: remoteFileSys->Read(“rutabaga”) Translated into call on server: fileSys->Read(“rutabaga”)

Remote Procedure Call (RPC) Implementation: Request-response message passing (under covers!) “Stub” provides glue on client/server. Client stub is responsible for “marshalling” arguments and “unmarshalling” the return values Server-side stub is responsible for “unmarshalling” arguments and “marshalling” the return values. Marshalling involves (depending on the system): converting values to a canonical form, serializing objects, copying arguments passed by reference, etc.

RPC Information Flow

Remote Procedure Call (RPC) Client stub: Build message Send message Wait for response Unpack reply Return result Server stub: Create N threads to wait for work to do Loop: Wait for command Decode and unpack request parameters Call procedure Build reply message with results Send reply

Remote Procedure Call (RPC) Comparison between RPC and procedure call What’s equivalent? Parameters – request message Result – reply message Name of procedure – passed in request message Return address – mbox2 (client return mail box)

RPC Details Stub generator: Compiler that generates stubs Input: interface definitions in an “interface definition language (IDL)” Contains, among other things, types of arguments/return Output: stub code in the appropriate source language Code for client to pack message, send it off, wait for result, unpack result and return to caller Code for server to unpack message, call procedure, pack results, send them off

RPC Details (cont’d) Cross-platform issues: What if client/server machines are different architectures or in different languages? Convert everything to/from some canonical form Tag every item with an indication of how it is encoded (avoids unnecessary conversions). How does client know which mbox to send to? Need to translate name of remote service into network endpoint (Remote machine, port, possibly other info) Binding: the process of converting a user-visible name into a network endpoint This is another word for “naming” at network level Static: fixed at compile time Dynamic: performed at runtime

RPC Details (cont’d) Dynamic Binding Most RPC systems use dynamic binding via name service Name service provides dynamic translation of servicembox Why dynamic binding? Access control: check who is permitted to access service Fail-over: If server fails, use a different one What if there are multiple servers? Could give flexibility at binding time Choose unloaded server for each new client Could provide same mbox (router level redirect) Choose unloaded server for each new request Only works if no state carried from one call to next What if multiple clients? Pass pointer to client-specific return mbox in request

Problems with RPC Non-Atomic failures Different failure modes in distributed system than on a single machine Consider many different types of failures User-level bug causes address space to crash Machine failure, kernel bug causes all processes on same machine to fail Some machine is compromised by malicious party Before RPC: whole system would crash/die After RPC: One machine crashes/compromised while others keep working Can easily result in inconsistent view of the world Did my cached data get written back or not? Did server do what I requested or not? Answer? Distributed transactions/Byzantine Commit

Problems with RPC (cont’d) Performance Cost of Procedure call « same-machine RPC « network RPC Means programmers must be aware that RPC is not free Caching can help, but may make failure handling complex

Cross-Domain Communication/Location Transparency How do address spaces communicate with one another? Shared Memory with Semaphores, monitors, etc… File System Pipes (1-way communication) “Remote” procedure call (2-way communication) RPC’s can be used to communicate between address spaces on different machines, on the same machine Services can be run wherever it’s most appropriate Access to local and remote services looks the same Examples of modern RPC systems: CORBA (Common Object Request Broker Architecture) DCOM (Distributed COM) RMI (Java Remote Method Invocation)