Distributed systems Programming with threads. Reviews on OS concepts Each process occupies a single address space.

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
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.
Distributed Object & Remote Invocation Vidya Satyanarayanan.
Remote Procedure CallCS-4513, D-Term Remote Procedure Call CS-4513 Distributed Computing Systems (Slides include materials from Operating System.
Multiple Processor Systems
Lightweight Remote Procedure Call Brian N. Bershad, Thomas E. Anderson, Edward D. Lazowska, and Henry M. Levy Presented by Alana Sweat.
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.
Distributed systems Programming with threads. Reviews on OS concepts Each process occupies a single address space.
Distributed Systems Lecture #3: Remote Communication.
CS533 Concepts of Operating Systems Class 20 Summary.
Threads 1 CS502 Spring 2006 Threads CS-502 Spring 2006.
Learning Objectives Understanding the difference between processes and threads. Understanding process migration and load distribution. Understanding Process.
Middleware Technologies compiled by: Thomas M. Cosley.
Implementing Remote Procedure Calls an introduction to the fundamentals of RPCs, made during the advent of the technology. what is an RPC? what different.
16: Distributed Systems1 DISTRIBUTED SYSTEM STRUCTURES NETWORK OPERATING SYSTEMS The users are aware of the physical structure of the network. Each site.
Remote Procedure Calls. 2 Client/Server Paradigm Common model for structuring distributed computations A server is a program (or collection of programs)
PRASHANTHI NARAYAN NETTEM.
.NET Mobile Application Development Introduction to Mobile and Distributed Applications.
Threads Chapter 4. Modern Process & Thread –Process is an infrastructure in which execution takes place  (address space + resources) –Thread is a program.
CS510 Concurrent Systems Jonathan Walpole. Lightweight Remote Procedure Call (LRPC)
1 Chapter Client-Server Interaction. 2 Functionality  Transport layer and layers below  Basic communication  Reliability  Application layer.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 12 Communicating over.
Introduction to Threads CS240 Programming in C. Introduction to Threads A thread is a path execution By default, a C/C++ program has one thread called.
Operating Systems ECE344 Ashvin Goel ECE University of Toronto Threads and Processes.
Operating Systems ECE344 Ashvin Goel ECE University of Toronto OS Design.
Implementing Remote Procedure Calls Authored by Andrew D. Birrell and Bruce Jay Nelson Xerox Palo Alto Research Center Presented by Lars Larsson.
Background: Operating Systems Brad Karp UCL Computer Science CS GZ03 / M th November, 2008.
3.1 Silberschatz, Galvin and Gagne ©2009Operating System Concepts with Java – 8 th Edition Chapter 3: Processes.
1 Threads, SMP, and Microkernels Chapter 4. 2 Process Resource ownership: process includes a virtual address space to hold the process image (fig 3.16)
CSE 451: Operating Systems Winter 2015 Module 22 Remote Procedure Call (RPC) Mark Zbikowski Allen Center 476 © 2013 Gribble, Lazowska,
CS333 Intro to Operating Systems Jonathan Walpole.
Shuman Guo CSc 8320 Advanced Operating Systems
Introduction to Operating Systems and Concurrency.
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.
Remote Procedure Call and Serialization BY: AARON MCKAY.
09/14/05 1 Implementing Remote Procedure Calls* Birrell, A. D. and Nelson, B. J. Presented by Emil Constantinescu *ACM Trans. Comput. Syst. 2, 1 (Feb.
Manish Kumar,MSRITSoftware Architecture1 Remote procedure call Client/server architecture.
Threads. Readings r Silberschatz et al : Chapter 4.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 4: Threads.
Implementing Remote Procedure Call Landon Cox February 12, 2016.
Computer Science Lecture 4, page 1 CS677: Distributed OS Last Class: RPCs RPCs make distributed computations look like local computations Issues: –Parameter.
Lecture 5: RPC (exercises/questions). 26-Jun-16COMP28112 Lecture 52 First Six Steps of RPC TvS: Figure 4-7.
Object Interaction: RMI and RPC 1. Overview 2 Distributed applications programming - distributed objects model - RMI, invocation semantics - RPC Products.
Introduction to threads
Threads Some of these slides were originally made by Dr. Roger deBry. They include text, figures, and information from this class’s textbook, Operating.
Client-Server Communication
CS533 Concepts of Operating Systems
CS399 New Beginnings Jonathan Walpole.
CSE 451: Operating Systems Winter 2006 Module 20 Remote Procedure Call (RPC) Ed Lazowska Allen Center
Sarah Diesburg Operating Systems COP 4610
CSE 451: Operating Systems Autumn 2003 Lecture 16 RPC
Threads Chapter 4.
CSE 451: Operating Systems Winter 2007 Module 20 Remote Procedure Call (RPC) Ed Lazowska Allen Center
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
Why Threads Are A Bad Idea (for most purposes)
Lecture 6: RPC (exercises/questions)
CSE 451: Operating Systems Autumn 2010 Module 21 Remote Procedure Call (RPC) Ed Lazowska Allen Center
Lecture 6: RPC (exercises/questions)
Lecture 7: RPC (exercises/questions)
Why Threads Are A Bad Idea (for most purposes)
CSE 451: Operating Systems Winter 2003 Lecture 16 RPC
Operating System Overview
Why Threads Are A Bad Idea (for most purposes)
CSE 451: Operating Systems Messaging and Remote Procedure Call (RPC)
Presentation transcript:

Distributed systems Programming with threads

Reviews on OS concepts Each process occupies a single address space

Reviews on OS concepts A thread of (execution) control has its own PC counter, stack pointer etc within a process.

Thread vs. Process Why threads? –Thread allows running code concurrently within a single process –Switching among threads is light-weight –Sharing data among threads requires no inter-process communication Why processes? –Fault isolation: One buggy process cannot crash others

Why concurrent programming? Exploit multiple CPUs (multi-core) Exploit I/O concurrency –Do some processing while waiting for disk (network, terminals, etc.) Responsive GUI –Respond to users while doing processing in the background Reduce latency of networked services –Servers serve multiple requests in parallel –Clients issue multiple requests in parallel

Single threaded servers do not fully utilize I/O and CPU time CPU usage disk usage Network usage

Multi-threaded servers achieve I/O concurrency time CPU usage disk usage Network usage

Designing a thread interface Create and manage threads –pthread_create, pthread_exit, pthread_join Provide mutual exclusion –pthread_mutex_lock, pthread_mutex_unlock Coordinate among multiple threads –pthread_cond_wait, pthread_cond_signal

Common Pitfalls Race condition Deadlock –Better bugs than race Wrong lock granularity –Leads to race or bad performance! Starvation

Remote procedure calls

RPC abstraction Everyone loves procedure calls –Transfer control and data on local programs RPC goal: make client/server communication look like procedure calls Easy to write programs with –Procedure calls are a well-understood model –RPC hides details of passing data between nodes

RPC vs. alternatives Alternatives: –Sockets –MPI –Distributed shared memory (later classes) –Map/Reduce, Dryad (later classes) RPC is very popular in programming distributed systems –XML RPC –Java RMI –Sun RPC

RPC architecture overview Servers export their local procedure APIs On client, RPC library generates RPC requests over network to server On server, called procedure executes, result returned in RPC response to client

RPC architecture transmit wait receive marshal args unmarshal args App Client RPC client library rpc call return receive transmit marshal args unmarshal args App Server rpc handler rpc handler return RPC server library RPC request RPC response work

Key challenges of RPC RPC semantics in the face of –Communication failures delayed and lost messages connection resets expected packets never arrive –Machine failures Server or client failures Did server fail before or after processing the request? –Might be impossible to tell communication failures from machine failures

RPC failure semantics RPC might return “failure” instead of results What are the possible outcomes in the face of failures? –Procedure did not execute –Procedure executed once –Procedure executed many times –Procedure partially executed Desired semantics: at-most-once

YFS’s RPC library transmit wait receive marshal args unmarshal args lock_client rpcc rpc call return receive transmit marshal args unmarshal args lock_server rpc handler rpc handler return RPC request RPC response work rpcs cl->call(lock_protocol::acquire, x, ret) Server.reg(lock_protocol::acquire, &ls, &lock_server::acquire)

RPC semantics Does yfs rpc implement at-most-once semantics? How would the lack of at-most-once affect applications?

Interactions between threads and RPCs Can a client hold locks across RPCs? Should it do so? client_func() { pthread_mutex_lock(&cl_lock); cl_rpcc->call(….) pthread_mutex_unlock(&cl_lock); }

Interactions between threads and RPC How about this client side code? client_func() { pthread_lock(&cl_lock); for (vector ::iterator i = list.begin(); i != list.end(); i++) { pthread_mutex_unlock(&cl_lock); (*i).call(….) pthread_mutex_lock(&cl_lock); }

Interactions between threads and RPCs Can a server make a RPC call during RPC handler?