Introduction to Concurrency Kenneth M Anderson University of Colorado Boulder CSCI 5828 Lecture 4 01 22 2008 University of Colorado 2009 1 Credit where Credit is Due 2 Some text and images for this lecture come from the lecture materials provided by the publisher of the Magee Kramer textbook As such some material is copyright 2006 John Wiley Sons Ltd Lecture Goals Review material in Chapter 1 of the Magee Kramer book What do we mean by concurrent programs What do we mean by model based software engineering Examine fundamental approach used in this book Concepts Modeling Practice 3 More on the Authors The Two Jeffs Jeff Kramer Dean of the Faculty of Engineering and Professor of Distributed Computing at the Department of Computing at Imperial College London ACM Fellow Editor of IEEE s Transactions on Software Engineering Winner of numerous software engineering awards including best paper and outstanding research awards Jeff Magee Professor at the Department of Computing at Imperial College London Long time member of the SE community with more than 70 journal and conference publications This book is based on their SE research into modeling concurrency over the past 20 years 4 Why worry 5 Concurrency is hard and I ve only ever needed singlethreaded programs Why should I care about it Answer multi core computers increasing use of clusters Growth rates for chip speed are flattening lets wait a year and our system will run faster No longer Instead chips are becoming wider more cores wider bus more data at a time more memory As chips are not getting faster the same way they used to a single threaded single process application is not going to see any significant performance gains from new hardware New Model Instead the way in which software will see performance gains with new hardware is if they are designed to get faster the more processors they have available This is not easy the computations that an application performs has to be amenable to parallelization Such an application will see noticeable speed improvements when run on machines with more processors Laptops currently have 2 cores will soon have 4 cores and Intel has an 80 core beast waiting in the wings A system written for n cores could potentially see an 80x speed up when run on such a machine 6 In addition 7 Concurrent programming is becoming hard to ignore In addition to the increasing presence of multi core computers there are lots of other domains in which concurrency is the norm Embedded software systems robotics command and control highperformance computing use of clusters Closer to home Web programming often requires concurrent programming AJAX Web browsers are examples of multi threaded GUI applications without threads the UI would block as information is downloaded BUT While concurrency is widespread it is also error prone Programmers trained on single threaded programs face unfamiliar problems synchronization race conditions deadlocks etc Example Therac 25 Concurrent programming errors contributed to accidents causing death and serious injury Mars Rover Problems with interaction between concurrent tasks caused periodic software resets reducing availability for exploration 8 Basics Single Thread Single Process Single Machine Thread Data Code Process Machine Sequential Program Single Thread of Control 9 Basics Multiple Thread Single Process Single Machine Thread Thread Data Code Process Machine Concurrent Program Multiple Threads of Control 10 Multi Thread But is it truly parallel Thread Thread Data Code Process Machine Concurrent Program Multiple Threads of Control 11 Multi Thread But is it truly parallel Thread We may have multiple threads in this process but we may not have events truly occurring in parallel Why not Thread Data Code Process Machine Concurrent Program Multiple Threads of Control 11 Multi Thread But is it truly parallel Thread Thread Data Code We may have multiple threads in this process but we may not have events truly occurring in parallel Why not It depends on the machine If the machine has multiple processors then true parallelism can Machine occur Otherwise parallelism is simulated Concurrent Program Multiple Threads of Control Process 11 Basics Single Thread Multiple Process Single Machine Thread Thread Data Code Process Thread Data Code Process Data Code Process Machine 12 Basics Multi thread Multi Process Single Machine Thread Thread Data Code Process Thread Thread Data Code Process Thread Thread Data Code Process Machine Note You can have way more than just two threads per process 13 Basics Multi everything Thread Thread Data Code Thread Thread Data Code Process Thread Thread Data Code Process Process Machine Thread Thread Data Code Process Thread Thread Data Code Process Thread Thread Data Code Process Machine 14 Applications are Dead Long Live Applications Due to the ability to have multiple threads multiple processes and multiple machines work together on a single problem the notion of an application is changing It used to be that Thread Application Data Code Process 15 Now we might refer to this as an application Multiple Thread Single Process Single Machine Thread Basics Multiple Thread Single Process Single Machine Thread Thread Data Code Thread Data Code Process Process Machine Machine multi threaded client multi threaded server that in turn relies on a cluster of machines to service the request 6 6 Data Code Data Code Data Code Data Code Data Code Data Code Data Code Data Code Data Code Process Process Process Data Code Data Code Data Code Process Process Process Data Code Data Code Data Code Process Process Process Data Code Data Code Data Code Process Process Process Data Code Data Code Data Code Process Process Process Data Code Data Code Data Code Process Process Process Data Code Data Code Data Code Process Process Process Data Code Data Code Data Code Process Process Process Process Process Process Process Process Process Machine Machine Machine Machine Machine Machine Machine Machine Machine Machine 16 Now we might refer to this as an application Multiple Thread Single Process Single Machine Thread Basics Multiple Thread Single Process Single Machine Thread Thread Data Code Thread Data Code Process Process Machine Machine multi threaded client multi threaded server that in turn relies on a cluster of machines to service the request 6 For instance we might call this Google 6 Data Code Data Code Data Code Data Code Data Code Data Code Data Code Data Code Data Code Process
View Full Document
Unlocking...