Applying ... Co631 (Concurrency) Peter Welch

Slides:



Advertisements
Similar presentations
Operating Systems: Monitors 1 Monitors (C.A.R. Hoare) higher level construct than semaphores a package of grouped procedures, variables and data i.e. object.
Advertisements

CS252: Systems Programming Ninghui Li Based on Slides by Prof. Gustavo Rodriguez-Rivera Topic 14: Deadlock & Dinning Philosophers.
Deadlock Prevention, Avoidance, and Detection
Concurrency: Deadlock and Starvation Chapter 6. Deadlock Permanent blocking of a set of processes that either compete for system resources or communicate.
Operating Systems Lecture Notes Deadlocks Matthew Dailey Some material © Silberschatz, Galvin, and Gagne, 2002.
6. Deadlocks 6.1 Deadlocks with Reusable and Consumable Resources
Mutual Exclusion By Shiran Mizrahi. Critical Section class Counter { private int value = 1; //counter starts at one public Counter(int c) { //constructor.
Chapter 6: Process Synchronization
1 Operating Systems, 122 Practical Session 5, Synchronization 1.
CY2003 Computer Systems Lecture 05 Semaphores - Theory.
SPL/2010 Liveness And Performance 1. SPL/2010 Performance ● Throughput - How much work can your program complete in a given time unit? ● Example: HTTP.
Classic Synchronization Problems
Chapter 6 Concurrency: Deadlock and Starvation
1 Introduction to Computability Theory Lecture12: Reductions Prof. Amos Israeli.
Ken Birman. Dining Philosophers A problem that was invented to illustrate some issues related to synchronization with objects Our focus here is on the.
Classical Problems of Concurrency
Concurrent Processes Lecture 5. Introduction Modern operating systems can handle more than one process at a time System scheduler manages processes and.
OS Spring 2004 Concurrency: Principles of Deadlock Operating Systems Spring 2004.
Process Synchronization
OS Fall’02 Concurrency: Principles of Deadlock Operating Systems Fall 2002.
CS 603 Dining Philosopher’s Problem February 15, 2002.
Chapter 6 Concurrency: Deadlock and Starvation
CSC321 §9 Deadlock 1 Section 9 Deadlock. CSC321 §9 Deadlock 2 Deadlock: four necessary and sufficient conditions  Serially reusable resources: the processes.
CS 149: Operating Systems February 17 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak
© P. H. Welch1 Applying... Chapter 6. © P. H. Welch2 Integrator Component with Reset Line int.2 in out reset PROC int.2 (CHAN OF REAL64 in, reset, out)
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Classical problems.
Dining Philosophers A “Classical” Synchronization Problem devised by Edsger Dijkstra in 1965 (modified for the masses by Tony Hoare) You have –5 philosophers.
Copyright © Curt Hill Concurrent Execution An Overview for Database.
Chapter 7 Deadlocks. 7.1 Introduction Deadlock Common approaches to deal with deadlock – Prevention – Avoidance – Detection and recovery.
Operating Systems COMP 4850/CISG 5550 Deadlocks Dr. James Money.
Review: Monitor Semantics If P does X.wait() and later Q does X.signal(): –Hoare Semantics: Q blocks yielding the monitor immediately to P –Mesa Semantics:
Types and Programming Languages Lecture 3 Simon Gay Department of Computing Science University of Glasgow 2006/07.
Chapter 8 Deadlocks. Objective System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance Deadlock Detection.
Silberschatz, Galvin and Gagne ©2009 Edited by Khoury, 2015 Operating System Concepts – 9 th Edition, Chapter 7: Deadlocks.
Rensselaer Polytechnic Institute CSCI-4210 – Operating Systems David Goldschmidt, Ph.D.
ICS Deadlocks 6.1 Deadlocks with Reusable and Consumable Resources 6.2 Approaches to the Deadlock Problem 6.3 A System Model –Resource Graphs –State.
Slide 10-1 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 10.
Process Management Deadlocks.
Synchronization Deadlocks and prevention
Concurrency: Deadlock and Starvation
Operating systems Deadlocks.
ITEC 202 Operating Systems
Virtual Memory Networks and Communication Department.
Chapter 7 – Deadlock and Indefinite Postponement
Deadlocks (part II) Deadlock avoidance – (not reasonable)
Deadlock B.Ramamurthy CSE421 9/17/2018 B.Ramamurthy.
5-High-Performance Embedded Systems using Concurrent Process (cont.)
Operating System: DEADLOCKS
Introduction to Operating Systems
Chapter 7 Deadlock.
Lecture 25 Syed Mansoor Sarwar
Liveness And Performance
What Are They? Who Needs ‘em? An Example: Scoring in Tennis
Operating systems Deadlocks.
Critical section problem
Chapter 7: Synchronization Examples
Semaphores Chapter 6.
Concurrency: Mutual Exclusion and Process Synchronization
SE350: Operating Systems Lecture 5: Deadlock.
CSE 153 Design of Operating Systems Winter 19
Operating System 6 CONCURRENCY: MUTUAL EXCLUSION AND SYNCHRONIZATION
Deadlock B.Ramamurthy CSE421 4/26/2019 B.Ramamurthy.
CSE 380 Lecture Note 12 Insup Lee
CENG334 Introduction to Operating Systems
“The Little Book on Semaphores” Allen B. Downey
Chapter 7: Deadlocks.
EECE.4810/EECE.5730 Operating Systems
CSE 542: Operating Systems
CSE 542: Operating Systems
Presentation transcript:

Applying ... Co631 (Concurrency) Peter Welch (p.h.welch@kent.ac.uk) Computing Laboratory, University of Kent at Canterbury Co631 (Concurrency) 27-Nov-18 Copyright P.H.Welch

Applying … The dining philosophers ... Compiling … 11/27/2018 Applying … The dining philosophers ... Compiling … Real-time inference engine … Fast fourier transform … Computing on global data … Neural nets … Microprocessor design … Autonomous robots ... 27-Nov-18 Copyright P.H.Welch

The Dining Philosophers Once upon a time, five philosophers lived in the same college. They were proud, independent philosophers who thought independent thoughts and never communicated with each other (or with anyone else, for that matter) what these thoughts might have been. From time to time, each philosopher would get hungry. At such times, she (or he) would stop thinking and go to the single dining room in the college – shared by all the philosophers. 27-Nov-18 Copyright P.H.Welch

The Dining Philosophers The dining room contained one circular table, around which were symmetrically placed five chairs. Each chair was labelled with the name of one of the philosophers and each philosopher was only allowed to sit in her/his own chair. 27-Nov-18 Copyright P.H.Welch

The Dining Philosophers F4 F3 F2 F1 F0 Opposite each chair was a plate and, between the plates, was laid a single golden fork. In the centre of the table was a large bowl of spaghetti, which was constantly replenished. 27-Nov-18 Copyright P.H.Welch

The Dining Philosophers F4 F3 F2 F1 F0 The philosophers never managed to master the art of serving, or indeed, eating the spaghetti with a single fork. To eat, they had to pick up two forks – one from each side of their plates. 27-Nov-18 Copyright P.H.Welch

The Dining Philosophers F4 F0 P0 P1 P2 P3 P4 F1 F3 F2 The philosophers never managed to master the art of serving, or indeed, eating the spaghetti with a single fork. To eat, they had to pick up two forks – one from each side of their plates. 27-Nov-18 Copyright P.H.Welch

The Dining Philosophers  F4 F0 P0 P1 P2 P3 P4 F1 F3 F2 If a fork was being used by a neighbouring philosopher, a hungry philosopher anxiously waited for the neighbour to finish eating. 27-Nov-18 Copyright P.H.Welch

The Dining Philosophers   F4 F0 P0 P1 P2 P3 P4 F1    F3 F2 If a fork was being used by a neighbouring philosopher, a hungry philosopher anxiously waited for the neighbour to finish eating. This was the only occasion when the existence of one philosopher had an impact on the life of another ... 27-Nov-18 Copyright P.H.Welch

The Dining Philosophers   F4 F0 P0 P1 P2 P3 P4 F1    F3 F2 The philosophers lived like this for years and years until, one day, something most unfortunate happened. 27-Nov-18 Copyright P.H.Welch

The Dining Philosophers   P0 P1 P2 P3 P4 F4 F3 F2 F1 F0    The philosophers lived like this for years and years until, one day, something most unfortunate happened. The philosophers lived like this for years and years until, one day, something most unfortunate happened. By chance, all the philosophers got hungry at the same time, went to the dining room, sat down and reached for the forks. 27-Nov-18 Copyright P.H.Welch

The Dining Philosophers   P0 P1 P2 P3 P4 F4 F3 F2 F1 F0    By further chance, each philosopher picked up the fork on her/his left. 27-Nov-18 Copyright P.H.Welch

The Dining Philosophers   F0 P0 P1 P2 P3 P4 F1 F4   F2 F3  By further chance, each philosopher picked up the fork on her/his left. Noticing that the other fork was being used, all philosophers waited for their neighbours to finish ............... and waited ... and waited ... and waited ........... 27-Nov-18 Copyright P.H.Welch

The Dining Philosophers   F0 P0 P1 P2 P3 P4 F1 DEADLOCK !!! F4   F2 F3  By further chance, each philosopher picked up the fork on her/his left. Noticing that the other fork was being used, all philosophers waited for their neighbours to finish ............... and waited ... and waited ... and waited ........... and waited ... and waited ... and waited ........... and starved to death! 27-Nov-18 Copyright P.H.Welch

The Dining Philosophers  The story of The Dining Philosophers is due to Edsger Dijkstra – one of the founding fathers of Computer Science. It illustrates a classic problem in concurrency: how to share resources safely between competing consumers. http://www.cs.utexas.edu/users/EWD/ewd03xx/EWD310.PDF Historical document 27-Nov-18 Copyright P.H.Welch

The Dining Philosophers  In this example, the resources are the forks and the consumers are the philosophers. Problems arise because of the limited nature of the resources (only 5 forks) and because each consumer (5 of them) needs 2 forks at a time. The spaghetti is an infinite resource in this tale – so, plays no role in the catastrophe. Similarly, the college provides exclusive facilities for thinking (rooms) and eating (chairs and plates) for each philosopher – so, these also play no role. 27-Nov-18 Copyright P.H.Welch

The Dining Philosophers  The source of the story was a deadlock that would mysteriously arise from time to time in an early multiprocessing operating system. The philosophers are user processes that need file I/O. To read or write a file, a process has to acquire a data buffer (to smooth data transfer and make it fast). If 2 files need to be open at the same time, 2 buffers are needed. In those days, memory was scarce – so the number of buffers was limited. The forks are the buffers. 27-Nov-18 Copyright P.H.Welch

The Dining Philosophers  Today – some 34 years later – memory is not so scarce! Yet, operating system (or specific application) deadlock is rampant. How often does your whole PC (or one of its applications) lock up on you? We have been, and still are, making the same mistakes again and again and again ...      27-Nov-18 Copyright P.H.Welch

The Dining Philosophers   F0 P0 P1 P2 P3 P4 F1 DEADLOCK !!! F4   F2 F3  We’ll modify the system to eliminate deadlock presently. First, let’s model the system as it stands. Then, we can start reasoning about it! As discussed, the only significant players are the forks and the philosophers. We’ll start with the philosophers. 27-Nov-18 Copyright P.H.Welch

philosopher right left PROC philosopher (CHAN BOOL left!, right!) : This philosopher’s only point of contact with the rest of the world is when picking up the forks … 27-Nov-18 Copyright P.H.Welch

philosopher right left WHILE TRUE SEQ ... think PAR -- pick up forks left ! TRUE right ! TRUE ... eat PAR -- put down forks PROC philosopher (CHAN BOOL left!, right!) : world is when picking up the forks … the philosopher will be blocked if one or both are not there … This philosopher’s only point of contact with the rest of the world is when picking up the forks … 27-Nov-18 Copyright P.H.Welch

philosopher right left WHILE TRUE SEQ ... think PAR -- pick up forks left ! TRUE right ! TRUE ... eat PAR -- put down forks PROC philosopher (CHAN BOOL left!, right!) : This philosopher’s only point of contact with the rest of the world is when picking up the forks … world is when picking up the forks … the philosopher will never be blocked putting down the forks … 27-Nov-18 Copyright P.H.Welch

left right fork WHILE TRUE BOOL any: ALT left ? any -- left phil picks up left ? any -- left phil puts down right ? any -- right phil picks up right ? any -- right phil puts down PROC fork (CHAN BOOL left?, right?) : Once a fork has been picked up by a philosopher (say the one on its left), it waits to be put down by that philosopher (the one on its left). While it is being held by one, it cannot be picked up by another. 27-Nov-18 Copyright P.H.Welch

left right fork WHILE TRUE BOOL any: ALT left ? any -- left phil picks up left ? any -- left phil puts down right ? any -- right phil picks up right ? any -- right phil puts down PROC fork (CHAN BOOL left?, right?) : Once a fork has been picked up by a philosopher (say the one on its left), it waits to be put down by that philosopher (the one on its left). While it is being held by one, it cannot be picked up by another. 27-Nov-18 Copyright P.H.Welch

* NB: there are other ways ... left right fork WHILE TRUE BOOL any: ALT left ? any -- left phil picks up left ? any -- left phil puts down right ? any -- right phil picks up right ? any -- right phil puts down PROC fork (CHAN BOOL left?, right?) : Note: this fork process provides a mutual exclusion lock – commonly known as a ‘mutex’. If two processes must not engage in a particular activity at the same time, program them to acquire a mutex first ... and release it afterwards . * * NB: there are other ways ... 27-Nov-18 Copyright P.H.Welch

philosopher right left PROC philosopher (CHAN BOOL left!, right!) WHILE TRUE SEQ ... think PAR -- pick up forks left ! TRUE right ! TRUE ... eat PAR -- put down forks : For our philosopher processes, the competitive activity is using a particular fork. Only one may use it at a time ... Hence, it must acquire the fork before eating ... and release it afterwards. 27-Nov-18 Copyright P.H.Welch

The Dining Philosophers   F0 P0 P1 P2 P3 P4 F1 DEADLOCK !!! F4   F2 F3  Now, let’s build the college system ... which is simply all the philosophers and all the forks ... connected together correctly. The college is just a process. It is a closed system, currently, with no connections to the outside world. 27-Nov-18 Copyright P.H.Welch

P college r[0] l[0] l[4] l[3] l[2] l[1] r[4] r[3] r[2] r[1] F “l” = “left”, “r” = “right” channels (from the philosophers’ points of view) 27-Nov-18 Copyright P.H.Welch

[5]CHAN BOOL left, right: PAR i = 0 FOR 5 PAR college r[0] l[0] l[4] l[3] l[2] l[1] r[4] r[3] r[2] r[1] P F PROC college () [5]CHAN BOOL left, right: PAR i = 0 FOR 5 PAR philosopher (left[i]!, right[i]!) fork (left[i]?, right[(i+1)\5]?) : 27-Nov-18 Copyright P.H.Welch

The Dining Philosophers   F0 P0 P1 P2 P3 P4 F1 DEADLOCK !!! F4   F2 F3  Now, let’s eliminate the potential for deadlock in this system ... and prove it! 27-Nov-18 Copyright P.H.Welch

Ways to avoid this deadlock ... Buy one extra fork: Asymmetric solution. Also, the philosophers are very jealous and would not tolerate one of their number having more resources (an extra fork) than the others! Buy five extra forks: Too expensive!! The college is suffering from government cut-backs and the forks are made of gold. One of the philosophers picks up the right fork first: Asymmetric solution. Each philosopher would need to be told whether to go for the right or left first. Also, it forces the fork pick-ups to be done in sequence. Philosophers have two hands and want to use them in parallel. 27-Nov-18 Copyright P.H.Welch

Ways to avoid this deadlock ... External authority: College hires a security guard to whom each philosopher has to report when she wants to sit down at or stand up from the table. The security guard has instructions not to allow more than four philosophers at a time to sit down. This solution is symmetric (the philosophers still have equal, though reduced, rights), does not reduce concurrency (in the fork pick-ups) and is cheap (salaries are peanuts compared with the cost of extra forks). We’ll go for this one ... 27-Nov-18 Copyright P.H.Welch

P secure. college r[0] l[0] l[4] l[3] l[2] l[1] r[4] r[3] r[2] r[1] F u[0] d[0] u[1] d[1] u[2] d[2] u[3] d[3] d[4] u[4] security “d” = “down”, “u” = “up” channels (for indicating wish to sit down or stand up) 27-Nov-18 Copyright P.H.Welch

down ! TRUE -- get permission to sit down up philosopher right left WHILE TRUE SEQ ... think PAR -- pick up forks left ! TRUE right ! TRUE ... eat PAR -- put down forks down ! TRUE -- get permission to sit down PROC philosopher (CHAN BOOL left!, right!, down!, up!) : up ! TRUE -- notify security that -- you have finished 27-Nov-18 Copyright P.H.Welch

VAL INT max IS (SIZE down?) – 1: INITIAL INT n.sat.down IS 0: u[0] d[0] u[1] d[1] u[2] d[2] u[3] d[3] d[4] u[4] security VAL INT max IS (SIZE down?) – 1: INITIAL INT n.sat.down IS 0: PROC security ([]CHAN BOOL down?, up?) : WHILE TRUE BOOL any: ALT i = 0 FOR SIZE down? ALT (n.sat.down < max) & down[i] ? any n.sat.down := n.sat.down + 1 up[i] ? any n.sat.down := n.sat.down – 1 27-Nov-18 Copyright P.H.Welch

secure. college r[0] l[0] l[4] l[3] l[2] l[1] r[4] r[3] r[2] r[1] F u[0] d[0] u[1] d[1] u[2] d[2] u[3] d[3] d[4] u[4] “d” = “down”, “u” = “up” channels (for indicating wish to sit down or stand up) P security 27-Nov-18 Copyright P.H.Welch

[5]CHAN BOOL left, right: college r[0] l[0] l[4] l[3] l[2] l[1] r[4] r[3] r[2] r[1] F P PROC college () [5]CHAN BOOL left, right: PAR i = 0 FOR 5 PAR philosopher (left[i]!, right[i]!) fork (left[i]?, right [(i+1)\5]?) : 27-Nov-18 Copyright P.H.Welch

[5]CHAN BOOL left, right: [5]CHAN BOOL up, down: secure.college r[0] l[0] l[4] l[3] l[2] l[1] r[4] r[3] r[2] r[1] F u[0] d[0] u[1] d[1] u[2] d[2] u[3] d[3] d[4] u[4] P PROC secure.college () [5]CHAN BOOL left, right: [5]CHAN BOOL up, down: PAR i = 0 FOR 5 PAR philosopher (left[i]!, right[i]!, down[i]!, up[i]!) fork (left[i]?, right [(i+1)\5]?) : 27-Nov-18 Copyright P.H.Welch

[5]CHAN BOOL left, right: [5]CHAN BOOL up, down: PAR secure.college r[0] l[0] l[4] l[3] l[2] l[1] r[4] r[3] r[2] r[1] F u[0] d[0] u[1] d[1] u[2] d[2] u[3] d[3] d[4] u[4] security P PROC secure.college () [5]CHAN BOOL left, right: [5]CHAN BOOL up, down: PAR security (down?, up?) PAR i = 0 FOR 5 philosopher (left[i]!, right[i]!, down[i]!, up[i]!) fork (left[i]?, right [(i+1)\5]?) : 27-Nov-18 Copyright P.H.Welch

The potential for deadlock in college was not obvious to its designers. The claim that there is no such potential within secure.college should not be accepted lightly. We must provide a (formal) proof of the absence of deadlock in any safety-critical application. Systematic validation through “exhaustive” testing is unacceptable ... been there ... doesn’t work ... !!! 27-Nov-18 Copyright P.H.Welch

DEF (informal): DEADLOCK A network of processes is deadlocked when every process is blocked trying to communicate with other processes within that network. If any process within the network is blocked waiting for an external communication, its environment may eventually offer that communication – and the network would proceed. It is not deadlocked. If any process within the network is blocked on a timeout, that process will eventually continue – and the network is not deadlocked. A deadlocked network refuses all external events (communications, the passing of time, ...), as well as all internal activity. 27-Nov-18 Copyright P.H.Welch

DEF (informal): DEADLOCK A network of processes is deadlocked when every process is blocked trying to communicate with other processes within that network. Theorem: a deadlocked network will contain a cycle of processes with each process in the cycle blocked trying to communicate with the next node in the cycle. 27-Nov-18 Copyright P.H.Welch

This college may deadlock  r[0] l[0] l[4] l[3] l[2] l[1] r[4] r[3] r[2] r[1] P F ! ? This college may deadlock  Note the cycle of blocked communications 27-Nov-18 Copyright P.H.Welch

What about this one? secure. college F P r[0] l[0] l[4] l[3] l[2] l[1] d[0] u[1] d[1] u[2] d[2] u[3] d[3] d[4] u[4] P security What about this one? 27-Nov-18 Copyright P.H.Welch

ASSUME: secure.college is deadlocked … The claim that there is no deadlock within secure.college should not be accepted lightly. ASSUME: secure.college is deadlocked … In that case, all its processes – each philosopher, each fork and the security guard are blocked. Where might they be? The security guard can only be in one place – blocked on its ALT, waiting for a philosopher to enter/leave the dining room. 27-Nov-18 Copyright P.H.Welch

Waits for signals on up or down channels ... security Waits for signals on up or down channels ... VAL INT max IS (SIZE down?) – 1: INT n.sat.down: SEQ n.sat.down := 0 PROC security ([]CHAN BOOL down?, up?) : WHILE TRUE BOOL any: ALT i = 0 FOR SIZE down? ALT (n.sat.down < max) & down[i] ? any n.sat.down := n.sat.down + 1 up[i] ? any n.sat.down := n.sat.down – 1 27-Nov-18 Copyright P.H.Welch

ASSUME: secure.college is deadlocked … The claim that there is no deadlock within secure.college should not be accepted lightly. ASSUME: secure.college is deadlocked … In that case, all its processes – each philosopher, each fork and the security guard are blocked. Where might they be? The security guard can only be in one place – blocked on its ALT, waiting for a philosopher to enter/leave the dining room. Each fork is either on the table or in the hands of one of its neighbouring philosophers. 27-Nov-18 Copyright P.H.Welch

PROC fork (CHAN BOOL left?, right?) : WHILE TRUE BOOL any: ALT left ? any -- left phil picks up left ? any -- left phil puts down right ? any -- right phil picks up right ? any -- right phil puts down On table – waiting to be picked up ... Held by ‘left’ philosopher – waiting to be put down ... Held by ‘right’ philosopher – waiting to be put down ... 27-Nov-18 Copyright P.H.Welch

ASSUME: secure.college is deadlocked … The claim that there is no deadlock within secure.college should not be accepted lightly. ASSUME: secure.college is deadlocked … In that case, all its processes – each philosopher, each fork and the security guard are blocked. Where might they be? Each philosopher could be in one of several places – thinking, trying to get past security, trying to pick up its forks, eating, trying to put down its forks or trying to leave the dining room (i.e. telling security that it’s leaving). 27-Nov-18 Copyright P.H.Welch

Four must get past here … down up philosopher right left up ! TRUE -- notify security that -- you have finished down ! TRUE -- get permission to sit down WHILE TRUE SEQ ... think PAR -- pick up forks left ! TRUE right ! TRUE ... eat PAR -- put down forks PROC philosopher (CHAN BOOL left!, right!, down!, up!) : Can’t get stuck here! Four must get past here … 27-Nov-18 Copyright P.H.Welch

ASSUME: secure.college is deadlocked … The claim that there is no deadlock within secure.college should not be accepted lightly. ASSUME: secure.college is deadlocked … In that case, all its processes – each philosopher, each fork and the security guard are blocked. Where might they be? Therefore, one philosopher must be stuck trying to get past security. The other four must be in the dining room, trying to pick up their forks. No philosopher can have picked up both forks (else s/he would be eating – which is in the non-stuck region). 27-Nov-18 Copyright P.H.Welch

Four must get past here … down up philosopher right left up ! TRUE -- notify security that -- you have finished down ! TRUE -- get permission to sit down WHILE TRUE SEQ ... think PAR -- pick up forks left ! TRUE right ! TRUE ... eat PAR -- put down forks PROC philosopher (CHAN BOOL left!, right!, down!, up!) : Can’t get stuck here! Four must get past here … 27-Nov-18 Copyright P.H.Welch

secure. college r[0] l[0] l[4] l[3] l[2] l[1] r[4] r[3] r[2] r[1] F u[0] d[0] u[1] d[1] u[2] d[2] u[3] d[3] d[4] u[4] P security P Without loss of generality, suppose it’s the top philosopher who is not there. 27-Nov-18 Copyright P.H.Welch

Philosophers 1 and 4 must get the top forks … secure. college r[0] l[0] l[4] l[3] l[2] l[1] r[4] r[3] r[2] r[1] F u[0] d[0] u[1] d[1] u[2] d[2] u[3] d[3] d[4] u[4] P security P fork Philosophers 1 and 4 must get the top forks … 27-Nov-18 Copyright P.H.Welch

fork fork secure. college P F P d[0] u[1] d[1] u[2] d[2] u[3] d[3] d[4] u[4] P security P fork fork They can’t have both their forks – so philosophers 2 and 3 must have them … 27-Nov-18 Copyright P.H.Welch

Philosophers 2 and 3 can’t have both their forks … secure. college r[0] l[0] l[4] l[3] l[2] l[1] r[4] r[3] r[2] r[1] F u[0] d[0] u[1] d[1] u[2] d[2] u[3] d[3] d[4] u[4] P security P fork fork Philosophers 2 and 3 can’t have both their forks … 27-Nov-18 Copyright P.H.Welch

CONTRADICTION: the initial assumption (of deadlock) is impossible !!! secure. college r[0] l[0] l[4] l[3] l[2] l[1] r[4] r[3] r[2] r[1] F u[0] d[0] u[1] d[1] u[2] d[2] u[3] d[3] d[4] u[4] P security P fork CONTRADICTION: the initial assumption (of deadlock) is impossible !!! Q.E.D fork fork … but ONE WILL GET BOTH !!! 27-Nov-18 Copyright P.H.Welch

Exercise: Provide a similar (informal) proof that the other methods (slide 31) for ensuring freedom from deadlock do just that! 27-Nov-18 Copyright P.H.Welch

Exercise: Provide some links from secure.college to the outside world and animate an interactive demonstration of life inside. Modify the fork process so that it guarantees service on each input – even if one of them is perpetually busy. No philosopher must starve because of greedy colleagues! 27-Nov-18 Copyright P.H.Welch

reporting. college F P r[0] l[0] l[4] l[3] l[2] l[1] r[4] r[3] r[2] u[0] d[0] u[1] d[1] u[2] d[2] u[3] d[3] d[4] u[4] security 27-Nov-18 Copyright P.H.Welch

Applying … The dining philosophers ... Compiling … 11/27/2018 Applying … The dining philosophers ... Compiling … Real-time inference engine … Fast fourier transform … Computing on global data … Neural nets … Microprocessor design … Autonomous robots ... 27-Nov-18 Copyright P.H.Welch

11/27/2018 To appear ... 27-Nov-18 Copyright P.H.Welch

Applying … The dining philosophers ... Compiling … 11/27/2018 Applying … The dining philosophers ... Compiling … Real-time inference engine … Fast fourier transform … Computing on global data … Neural nets … Microprocessor design … Autonomous robots ... 27-Nov-18 Copyright P.H.Welch

11/27/2018 To appear ... 27-Nov-18 Copyright P.H.Welch

Applying … The dining philosophers ... Compiling … 11/27/2018 Applying … The dining philosophers ... Compiling … Real-time inference engine … Fast fourier transform … Computing on global data … Neural nets … Microprocessor design … Autonomous robots ... 27-Nov-18 Copyright P.H.Welch

11/27/2018 To appear ... 27-Nov-18 Copyright P.H.Welch

Applying … The dining philosophers ... Compiling … 11/27/2018 Applying … The dining philosophers ... Compiling … Real-time inference engine … Fast fourier transform … Computing on global data … Neural nets … Microprocessor design … Autonomous robots ... 27-Nov-18 Copyright P.H.Welch

11/27/2018 To appear ... 27-Nov-18 Copyright P.H.Welch

Applying … The dining philosophers ... Compiling … 11/27/2018 Applying … The dining philosophers ... Compiling … Real-time inference engine … Fast fourier transform … Computing on global data … Neural nets … Microprocessor design … Autonomous robots ... 27-Nov-18 Copyright P.H.Welch

11/27/2018 To appear ... 27-Nov-18 Copyright P.H.Welch

Applying … The dining philosophers ... Compiling … 11/27/2018 Applying … The dining philosophers ... Compiling … Real-time inference engine … Fast fourier transform … Computing on global data … Neural nets … Microprocessor design … Autonomous robots ... 27-Nov-18 Copyright P.H.Welch

11/27/2018 To appear ... 27-Nov-18 Copyright P.H.Welch

Applying … The dining philosophers ... Compiling … 11/27/2018 Applying … The dining philosophers ... Compiling … Real-time inference engine … Fast fourier transform … Computing on global data … Neural nets … Microprocessor design … Autonomous robots ... 27-Nov-18 Copyright P.H.Welch

11/27/2018 To appear ... 27-Nov-18 Copyright P.H.Welch