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 systems Programming with threads. Reviews on OS concepts Each process occupies a single address space.
Fast Communication Firefly RPC Lightweight RPC  CS 614  Tuesday March 13, 2001  Jeff Hoy.
Remote Procedure CallCS-4513, D-Term Remote Procedure Call CS-4513 Distributed Computing Systems (Slides include materials from Operating System.
Multiple Processor Systems
Distributed Systems Lecture #3: Remote Communication.
CS533 Concepts of Operating Systems Class 20 Summary.
Precept 3 COS 461. Concurrency is Useful Multi Processor/Core Multiple Inputs Don’t wait on slow devices.
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.
Threads CSCI 444/544 Operating Systems Fall 2008.
Implementing Remote Procedure Calls an introduction to the fundamentals of RPCs, made during the advent of the technology. what is an RPC? what different.
1 Chapter 4 Threads Threads: Resource ownership and execution.
Remote Procedure Calls. 2 Client/Server Paradigm Common model for structuring distributed computations A server is a program (or collection of programs)
An Introduction to Internetworking. Algorithm for client-server communication with UDP (connectionless) A SERVER A CLIENT Create a server-socket (listener)and.
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)
Chapter 51 Threads Chapter 5. 2 Process Characteristics  Concept of Process has two facets.  A Process is: A Unit of resource ownership:  a virtual.
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.
Processes and Threads Processes have two characteristics: – Resource ownership - process includes a virtual address space to hold the process image – Scheduling/execution.
Implementing Remote Procedure Calls Authored by Andrew D. Birrell and Bruce Jay Nelson Xerox Palo Alto Research Center Presented by Lars Larsson.
1 CMSC421: Principles of Operating Systems Nilanjan Banerjee Principles of Operating Systems Acknowledgments: Some of the slides are adapted from Prof.
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.
Brian N. Bershad, Thomas E. Anderson, Edward D. Lazowska, and Henry M. Levy. Presented by: Tim Fleck.
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.
6.894: Distributed Operating System Engineering Lecturers: Frans Kaashoek Robert Morris
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.
Chapter 4 Threads, SMP, and Microkernels Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E.
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.
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
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)
CSE 451: Operating Systems Winter 2003 Lecture 16 RPC
Operating System Overview
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 shared services –Servers serve 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 utilize resources more efficiently 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

Distributed Systems 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: –Socket programming –Distributed shared memory –MPI –Map/Reduce, Dryad (later class) RPC is a de facto way of 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

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 –Might be impossible to tell communication failures from machine failures

RPC failure RPCs can 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’ RPC library lock_clientlock_server rpcc rpcs marshal args transmit wait receive Unmarshal results transmit receive Unmarshal args marshal results Spawn new thread

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.being(); i != list.end(); i++) { pthread_mutex_unlock(&cl_lock); cl_rpcc->call(….) pthread_mutex_lock(&cl_lock); }

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