Concurrent & Distributed Systems Lecture 2: Introduction to interacting processes Recap –Concurrent processes could be pseudo-parallel Sharing a single.

Slides:



Advertisements
Similar presentations
Searching for Data Relationship between searching and sorting Simple linear searching Linear searching of sorted data Searching for string or numeric data.
Advertisements

Previously… Processes –Process States –Context Switching –Process Queues Threads –Thread Mappings Scheduling –FCFS –SJF –Priority scheduling –Round Robin.
Practice Quiz Question
8 Algorithms Foundations of Computer Science ã Cengage Learning.
Chapter 10 What's The Plan?: Algorithmic Thinking.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Introduction to Computers CS Dr. Zhizhang Shen Chapter 10: How to.
Data Structures Data Structures Topic #13. Today’s Agenda Sorting Algorithms: Recursive –mergesort –quicksort As we learn about each sorting algorithm,
Review: Chapters 1 – Chapter 1: OS is a layer between user and hardware to make life easier for user and use hardware efficiently Control program.
Concurrent & Distributed Systems Lecture 3: Processes interacting by sharing resources Asynchronous processes can interact by sharing a common resource.
Concurrent & Distributed Systems 1 Concurrent & Distributed Systems: Introduction What do we mean by Concurrent Systems? Why do we study them? Some more.
Concurrent Processes Lecture 5. Introduction Modern operating systems can handle more than one process at a time System scheduler manages processes and.
CS107 Introduction to Computer Science
1: Operating Systems Overview
Lecture 4: Computer Memory
CS107 Introduction to Computer Science Lecture 7, 8 An Introduction to Algorithms: Efficiency of algorithms.
SM3121 Software Technology Mark Green School of Creative Media.
Search Lesson CS1313 Spring Search Lesson Outline 1.Searching Lesson Outline 2.How to Find a Value in an Array? 3.Linear Search 4.Linear Search.
Basics of Operating Systems March 4, 2001 Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard.
LOGO OPERATING SYSTEM Dalia AL-Dabbagh
Operating System Review September 10, 2012Introduction to Computer Security ©2004 Matt Bishop Slide #1-1.
SOFTWARE DESIGN AND ARCHITECTURE LECTURE 09. Review Introduction to architectural styles Distributed architectures – Client Server Architecture – Multi-tier.
Sorting HKOI Training Team (Advanced)
Concurrency, Mutual Exclusion and Synchronization.
Analysis of Algorithms
Chapter 13 Recursion. Learning Objectives Recursive void Functions – Tracing recursive calls – Infinite recursion, overflows Recursive Functions that.
CS 61B Data Structures and Programming Methodology July 28, 2008 David Sun.
Games Development 2 Concurrent Programming CO3301 Week 9.
Systems Life Cycle. Know the elements of the system that are created Understand the need for thorough testing Be able to describe the different tests.
Simple Iterative Sorting Sorting as a means to study data structures and algorithms Historical notes Swapping records Swapping pointers to records Description,
Transactions with Unknown Duration for Web Services Patrick Sauter, Ingo Melzer.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Fluency with Information Technology Third Edition by Lawrence Snyder Chapter.
CY2003 Computer Systems Lecture 04 Interprocess Communication.
INFO1002 Systems Modelling Lecture 10 Establishing User Requirements Department of information Systems.
UNIT 5.  The related activities of sorting, searching and merging are central to many computer applications.  Sorting and merging provide us with a.
CS 206 Introduction to Computer Science II 09 / 18 / 2009 Instructor: Michael Eckmann.
CS399 New Beginnings Jonathan Walpole. 2 Concurrent Programming & Synchronization Primitives.
CS1Q Computer Systems Lecture 2 Simon Gay. Lecture 2CS1Q Computer Systems - Simon Gay2 Binary Numbers We’ll look at some details of the representation.
Concurrency Properties. Correctness In sequential programs, rerunning a program with the same input will always give the same result, so it makes sense.
Systems Development The Kingsway School. Systems Development This is carried out when a company is having a problem. They usually employ an ICT Consultant.
CS 206 Introduction to Computer Science II 01 / 30 / 2009 Instructor: Michael Eckmann.
Intro To Algorithms Searching and Sorting. Searching A common task for a computer is to find a block of data A common task for a computer is to find a.
8.1 8 Algorithms Foundations of Computer Science  Cengage Learning.
Searching Topics Sequential Search Binary Search.
Aims: To learn about some simple sorting algorithms. To develop understanding of the importance of efficient algorithms. Objectives: All:Understand how.
Lecture 4 Page 1 CS 111 Online Modularity and Memory Clearly, programs must have access to memory We need abstractions that give them the required access.
CS 179: GPU Computing LECTURE 2: MORE BASICS. Recap Can use GPU to solve highly parallelizable problems Straightforward extension to C++ ◦Separate CUDA.
6/27/20161 Operating Systems Design (CS 423) Elsa L Gunter 2112 SC, UIUC Based on slides by Roy Campbell, Sam King,
Lists and Sorting Algorithms
Component 1.6.
Searching and Sorting Algorithms
Memory Management.
CMPT 120 Topic: Searching – Part 2
CMSC201 Computer Science I for Majors Lecture 23 – Sorting
G.Anuradha Reference: William Stallings
Big O: Make it Simple Determine how complex the algorithm is, in relative to the size of the problem (e.g: List to be sorted) 'O' Stands for 'Order' -
Modularity and Memory Clearly, programs must have access to memory
Chapter 6: CPU Scheduling
Binary Search Back in the days when phone numbers weren’t stored in cell phones, you might have actually had to look them up in a phonebook. How did you.
Processor Management Damian Gordon.
CSCE 313 – Introduction to UNIx process
COMP60621 Fundamentals of Parallel and Distributed Systems
Concurrency: Mutual Exclusion and Process Synchronization
Chapter 10: Algorithm TECH Prof. Jeff Cheng.
What's The Plan?: Algorithmic Thinking
CS333 Intro to Operating Systems
What's The Plan?: Algorithmic Thinking
What's The Plan?: Algorithmic Thinking
COMP60611 Fundamentals of Parallel and Distributed Systems
Processor Management Damian Gordon.
Chapter 3: Process Management
Presentation transcript:

Concurrent & Distributed Systems Lecture 2: Introduction to interacting processes Recap –Concurrent processes could be pseudo-parallel Sharing a single CPU context switching between them Having the potential to be truly parallel if > 1 CPU available –Or they could be truly parallel But the distinction is not significant in 99% of cases Except for greater absolute speed and power available with > 1 CPU –Concurrent processes need to be interacting in some way to be interesting as a concurrent system This lecture considers two examples –A programming example – remember one reason for using concurrent programs is to be able to run parallel algorithms to make use of the greater power of parallel CPUs. This example shows that a parallel algorithm can be more efficient even if it runs on just one CPU, pseudo-parallel. –A distributed commercial application typical of very many real world systems. In both these examples, the processes interact and also give us our first look at potential problems in handling concurrent systems.

Concurrent & Distributed Systems A simple parallel algorithm for sorting: 1 Sorting is used extensively and often on a very large scale, so efficient algorithms and ones which can run on parallel machines are a must. Most sorting algorithms compare pairs and swap them if they are in the wrong order: Eg to sort the following list of 10 numbers in highest first order, lots of pairs would get compared and swapped if necessary …. eg [2 19] might get swapped to give a more ordered list such as: There are many algorithms, and one measure of how efficient they are is the number of ‘compare pair/swap’ operations they have to do to sort a list of length n. One example often taught to students is the ‘Bubble sort’ algorithm, where the number of compare/swaps is: cs = n(n-1)/2 ~ n 2 /2 So for n=10, cs = 45

Concurrent & Distributed Systems A simple parallel algorithm for sorting: 2 Now consider sorting the list in two halves, of 5 elements each [ ] and [ ] cs = 5(5-1)/2 + 5(5-1)/2 = 20, leaving 2 sorted half lists as below: [ ] and [ ] These need to be collated into a single list, which involves a further 10 compare/select operations (just a bit faster than compare/swap in fact), giving a total number of operations of 30. In general: nops ~ n 2 /2 (standard Bubble sort) nops ~ (n/2) 2 /2 +(n/2) 2 /2 + n = n 2 /4+n (half+half+collate) nops ~ n 2 /2p + n (dividing the sort into p sub-sorts) All this can be done on a single processor, context switching. It’s just a clever algorithm!

Concurrent & Distributed Systems A simple parallel algorithm for sorting: 3 If >1 processor is available, the sub-sorts could be done in parallel, in which case nops = n 2 /2p 2 (in parallel) + n. (We can ignore n when n large). With parallel collation, synchronisation will now be a problem!

Concurrent & Distributed Systems The Travel Agent example: 1 Imagine a (simple) country wide travel company, FastJet –It has offices in many towns –Each office has a terminal to the main HQ computer where all travel information is held (even if this company works with a distributed PC network, the key data about booking will still be in only one place and so this example will still be valid) Consider just 2 offices (London & Bristol) and just one flight (FJ23) to Majorca At either office, the following rough scenario might take place: - 1 customer LC enters, looks at some brochures, decides maybe for Majorca - 2 asks one of the staff (LS) for details - 3 LS logs on to system - 4 LS shows customer some hotel details, weather etc, on screen - 5 LC decides to book onto FJ23, n tickets so far issued for this flight, so OK. - 6 LS allocates FJ23 seat n+1 to LC - 7 LC eventually finds passport in handbag, after search - 8 LS enters LC’s personal details into system - 9 LS issues named ticket for seat n +1 to LC - 10 LC pays - 11 LC uses LS’s system to check some more stuff about Majorca, then leaves. All this might repeat later for another customer, also for FJ23

Concurrent & Distributed Systems The Travel Agent example: 2 Now imagine one afternoon in London & Bristol What goes on in London and Bristol is asynchronous! So we don’t know the precise order of things as seen by the main CPU And there can be many different orderings of what happens.

Concurrent & Distributed Systems The Travel Agent example: 3 In particular, the red bits matter. They are called Critical Sections of the processes Because the steps in each process are asynchronous (humans hesitate etc), the steps where n and tickets are accessed could be in more than one actual order – these are called the different possible scenarios. Imagine that at the start of the afternoon, n=50, then this happens: –α1then n=51, ticket [51] still blank –ß1then n=52, ticket [52] still blank –α2then n=52, ticket [52] issued to LC –β2then n=52, ticket [52] issued to BC ie seat 51 is not allocated, seat 52 has two tickets! Now think about other possible scenarios – some are OK, some not Now think how many scenarios are possible Now think if it matters whether there is is one computer or distributed PC’s CS’s share common resources - n and tickets[ ]

Concurrent & Distributed Systems Introduction to interacting processes: summary The previous two examples show processes interacting and that problems can easily arise if this is not controlled. –In the sorting example, if collating is a concurrent process then it has to be sychronised with the sub-sorts, otherwise the collating will be wrong. –In the Travel Agent example, if processes concurrently share a common resource, they can interfere with each other in its proper logical use and so cause actual errors (mis-allocated tickets). In this case the parts of the processes concerned, the Critical Sections, will need to made mutually exclusive. Both these examples give rise to Safety Problems, ie the outcomes of the processes is wrong. When multiple concurrent processes are asynchronous (which they usually are), there can be many detailed scenarios as to how the logical steps in each process progress in relation to each other – and this may or may not matter. If multi-threaded concurrent processes can produce multiple scenarios, then testing will be a lot harder than for single threaded processes.