SlideShare a Scribd company logo
1 of 11
Download to read offline
DINING PHILOSOPHER’S
PROBLEM
© Yash Mittal 1
THE PROBLEM
The Scenario
- 5 silent philosophers sit at a round table with 5 bowls of
spaghetti
- A fork is placed between each pair of adjacent philosophers
- Eating is NOT limited by amount of spaghetti left: infinite
supply assumed
The Rules
- Each philosopher must ‘alternately’ think and eat
- A philosopher can only eat spaghetti when he has both left
and right forks
- Each fork can be held by only 1 philosopher
- After eating, he needs to put down both forks so they
become available to others
- A philosopher can grab the fork on left or right as they
become available
→ He can’t start eating until he has both of them
© Yash Mittal 2
PROBLEMS
How to design a Concurrent Algorithm such that each philosopher won’t starve, i.e., he can
forever continue to alternate between eating and thinking assuming that any philosopher
cannot know when others may want to eat or think.
The problem was designed to illustrate the challenges of avoiding Deadlock – a system state in
which no progress is possible.
Resource Starvation
- A problem encountered in multitasking where a process is perpetually denied necessary
resources. Without them the process can never finish its task,
- Resource Starvation might occur independently if a particular philosopher is unable to acquire
both forks because of a timing problem.
Mutual Exclusion
- Ensuring that no 2 concurrent processes are in their critical section at the same time.
- A basic requirement in Concurrency Control to prevent race conditions.
© Yash Mittal 3
SOLUTIONS
Resource Hierarchy Solution
- Assigns a partial order to the resources (forks)
- All resources will be requested in order & no 2 resources unrelated by order
will ever be used by a single unit of work at the same time.
- Resources are numbered 1-5 and each philosopher will always pick up the
lower-numbered fork first and then the higher-numbered fork.
- If 4 of 5 philosophers simultaneously pick up their ‘low fork’, only 1 ‘high fork’
will remain on the table. So the 5th philosopher will NOT be able to pick up
any fork.
→ Also, only 1 philosopher will have access to the ‘high fork’  he will be
able to eat using 2 forks
- Not always practical if list of required resources is not completely known in
advance.
© Yash Mittal 4
Arbitrator Solution
- Guarantee that a philosopher can pick up only 2 solutions by introducing an
arbitrator, Ex: waiter.
→ In order to pick up the forks, a philosopher must ask waiter’s
permission
→ Waiter gives permission to only 1 philosopher at a time until he has
picked up both his forks
→ Putting down a fork is always allowed.
- Waiter is implemented as a mutex - a program object that allows multiple
program threads to share the same resource, such as file access, but not
simultaneously.
© Yash Mittal 5
Requirement Engineering
Requirements are of 2 types:
i. User
ii. System
a. Functional Requirements
b. Non-Functional Requirements
c. Domain Requirements
Process of identification of requirements is called Requirement Engineering.
Four phases
1. Requirement Discovery
2. Requirement Analysis
3. Requirement Validation
4. Requirement Management
© Yash Mittal 6
Requirement Discovery Phase
Scenario – based Modelling
Use Case Diagram
– Actor : Philosophers
– Use Cases : Thinking, Eating, Acquiring Resources (forks)
Composition of Scenario [EATING]
– Pre-Condition : Resources (forks) available
– Normal Flow : Philosopher  2 forks available  Eating spaghetti
 Finished  Put down forks  Thinking
– Abnormal Flow : Philosopher is eating
 Another philosopher avails resources (Deadlock)
– Other Activity : Resource is not available  Philosopher thinks
– Post-Condition : Free the resources (forks are available)
© Yash Mittal 7
Requirement Analysis Phase
3 Types of Modelling
i. Class/Object Models
ii. Flow Oriented Models
iii. Behaviour Models
Flow Oriented Models – Data Flow Diagrams
DFD Level 0
© Yash Mittal 8
DFD Level 1
© Yash Mittal 9
Behaviour Modelling
 State Diagram
 Sequence Diagram
© Yash Mittal 10
THANK YOU
© Yash Mittal 11

More Related Content

What's hot

dining philosophers problem using montiors
dining philosophers problem using montiorsdining philosophers problem using montiors
dining philosophers problem using montiorsWarda Chaudhry
 
Critical Section in Operating System
Critical Section in Operating SystemCritical Section in Operating System
Critical Section in Operating SystemMOHIT AGARWAL
 
Semaphores OS Basics
Semaphores OS BasicsSemaphores OS Basics
Semaphores OS BasicsShijin Raj P
 
Process synchronization in Operating Systems
Process synchronization in Operating SystemsProcess synchronization in Operating Systems
Process synchronization in Operating SystemsRitu Ranjan Shrivastwa
 
Methods for handling deadlocks
Methods for handling deadlocksMethods for handling deadlocks
Methods for handling deadlocksA. S. M. Shafi
 
Operating Systems - Process Synchronization and Deadlocks
Operating Systems - Process Synchronization and DeadlocksOperating Systems - Process Synchronization and Deadlocks
Operating Systems - Process Synchronization and DeadlocksMukesh Chinta
 
INTER PROCESS COMMUNICATION (IPC).pptx
INTER PROCESS COMMUNICATION (IPC).pptxINTER PROCESS COMMUNICATION (IPC).pptx
INTER PROCESS COMMUNICATION (IPC).pptxLECO9
 
Mutual Exclusion using Peterson's Algorithm
Mutual Exclusion using Peterson's AlgorithmMutual Exclusion using Peterson's Algorithm
Mutual Exclusion using Peterson's AlgorithmSouvik Roy
 
Threads (operating System)
Threads (operating System)Threads (operating System)
Threads (operating System)Prakhar Maurya
 
Operating System Deadlock Galvin
Operating System  Deadlock GalvinOperating System  Deadlock Galvin
Operating System Deadlock GalvinSonali Chauhan
 

What's hot (20)

dining philosophers problem using montiors
dining philosophers problem using montiorsdining philosophers problem using montiors
dining philosophers problem using montiors
 
Semaphores
SemaphoresSemaphores
Semaphores
 
Critical Section in Operating System
Critical Section in Operating SystemCritical Section in Operating System
Critical Section in Operating System
 
Semaphore
SemaphoreSemaphore
Semaphore
 
Deadlock Prevention
Deadlock PreventionDeadlock Prevention
Deadlock Prevention
 
Semaphores OS Basics
Semaphores OS BasicsSemaphores OS Basics
Semaphores OS Basics
 
Process synchronization in Operating Systems
Process synchronization in Operating SystemsProcess synchronization in Operating Systems
Process synchronization in Operating Systems
 
Methods for handling deadlocks
Methods for handling deadlocksMethods for handling deadlocks
Methods for handling deadlocks
 
Operating Systems - Process Synchronization and Deadlocks
Operating Systems - Process Synchronization and DeadlocksOperating Systems - Process Synchronization and Deadlocks
Operating Systems - Process Synchronization and Deadlocks
 
Process synchronization
Process synchronizationProcess synchronization
Process synchronization
 
Deadlock ppt
Deadlock ppt Deadlock ppt
Deadlock ppt
 
Semaphores
SemaphoresSemaphores
Semaphores
 
INTER PROCESS COMMUNICATION (IPC).pptx
INTER PROCESS COMMUNICATION (IPC).pptxINTER PROCESS COMMUNICATION (IPC).pptx
INTER PROCESS COMMUNICATION (IPC).pptx
 
Mutual Exclusion using Peterson's Algorithm
Mutual Exclusion using Peterson's AlgorithmMutual Exclusion using Peterson's Algorithm
Mutual Exclusion using Peterson's Algorithm
 
Threads (operating System)
Threads (operating System)Threads (operating System)
Threads (operating System)
 
Chapter 7 - Deadlocks
Chapter 7 - DeadlocksChapter 7 - Deadlocks
Chapter 7 - Deadlocks
 
OS - Deadlock
OS - DeadlockOS - Deadlock
OS - Deadlock
 
Operating System Deadlock Galvin
Operating System  Deadlock GalvinOperating System  Deadlock Galvin
Operating System Deadlock Galvin
 
CPU Scheduling Algorithms
CPU Scheduling AlgorithmsCPU Scheduling Algorithms
CPU Scheduling Algorithms
 
BANKER'S ALGORITHM
BANKER'S ALGORITHMBANKER'S ALGORITHM
BANKER'S ALGORITHM
 

Similar to Dining Philosopher's Problem

Deadlock _Classic problems.pptx
Deadlock _Classic problems.pptxDeadlock _Classic problems.pptx
Deadlock _Classic problems.pptxGopikaS12
 
Zuhri ramadhan dining philosophers theory and concept in operating system
Zuhri ramadhan   dining philosophers theory and concept in operating systemZuhri ramadhan   dining philosophers theory and concept in operating system
Zuhri ramadhan dining philosophers theory and concept in operating systemRaj Kamal
 
Biology Unit 1 Chapter 1 Lecture
Biology Unit 1 Chapter 1 LectureBiology Unit 1 Chapter 1 Lecture
Biology Unit 1 Chapter 1 Lecturepetruccis
 
Dining_Philosopher.pptx
Dining_Philosopher.pptxDining_Philosopher.pptx
Dining_Philosopher.pptxmuraridesai2
 

Similar to Dining Philosopher's Problem (6)

Deadlock.ppt
Deadlock.pptDeadlock.ppt
Deadlock.ppt
 
Deadlock _Classic problems.pptx
Deadlock _Classic problems.pptxDeadlock _Classic problems.pptx
Deadlock _Classic problems.pptx
 
Zuhri ramadhan dining philosophers theory and concept in operating system
Zuhri ramadhan   dining philosophers theory and concept in operating systemZuhri ramadhan   dining philosophers theory and concept in operating system
Zuhri ramadhan dining philosophers theory and concept in operating system
 
12 deadlock concept
12 deadlock concept12 deadlock concept
12 deadlock concept
 
Biology Unit 1 Chapter 1 Lecture
Biology Unit 1 Chapter 1 LectureBiology Unit 1 Chapter 1 Lecture
Biology Unit 1 Chapter 1 Lecture
 
Dining_Philosopher.pptx
Dining_Philosopher.pptxDining_Philosopher.pptx
Dining_Philosopher.pptx
 

More from Yash Mittal

Heathrow Airport - Refurbishment of Terminal 1
Heathrow Airport - Refurbishment of Terminal 1Heathrow Airport - Refurbishment of Terminal 1
Heathrow Airport - Refurbishment of Terminal 1Yash Mittal
 
Ruby on Rails & Version Control
Ruby on Rails & Version ControlRuby on Rails & Version Control
Ruby on Rails & Version ControlYash Mittal
 
Social Media & Networking - Boon or Bane?
Social Media & Networking - Boon or Bane?Social Media & Networking - Boon or Bane?
Social Media & Networking - Boon or Bane?Yash Mittal
 
Apple Inc's Financial Analysis
Apple Inc's Financial AnalysisApple Inc's Financial Analysis
Apple Inc's Financial AnalysisYash Mittal
 
Panasonic information systems
Panasonic information systemsPanasonic information systems
Panasonic information systemsYash Mittal
 

More from Yash Mittal (6)

Heathrow Airport - Refurbishment of Terminal 1
Heathrow Airport - Refurbishment of Terminal 1Heathrow Airport - Refurbishment of Terminal 1
Heathrow Airport - Refurbishment of Terminal 1
 
Direct X
Direct XDirect X
Direct X
 
Ruby on Rails & Version Control
Ruby on Rails & Version ControlRuby on Rails & Version Control
Ruby on Rails & Version Control
 
Social Media & Networking - Boon or Bane?
Social Media & Networking - Boon or Bane?Social Media & Networking - Boon or Bane?
Social Media & Networking - Boon or Bane?
 
Apple Inc's Financial Analysis
Apple Inc's Financial AnalysisApple Inc's Financial Analysis
Apple Inc's Financial Analysis
 
Panasonic information systems
Panasonic information systemsPanasonic information systems
Panasonic information systems
 

Recently uploaded

Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 

Recently uploaded (20)

Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 

Dining Philosopher's Problem

  • 2. THE PROBLEM The Scenario - 5 silent philosophers sit at a round table with 5 bowls of spaghetti - A fork is placed between each pair of adjacent philosophers - Eating is NOT limited by amount of spaghetti left: infinite supply assumed The Rules - Each philosopher must ‘alternately’ think and eat - A philosopher can only eat spaghetti when he has both left and right forks - Each fork can be held by only 1 philosopher - After eating, he needs to put down both forks so they become available to others - A philosopher can grab the fork on left or right as they become available → He can’t start eating until he has both of them © Yash Mittal 2
  • 3. PROBLEMS How to design a Concurrent Algorithm such that each philosopher won’t starve, i.e., he can forever continue to alternate between eating and thinking assuming that any philosopher cannot know when others may want to eat or think. The problem was designed to illustrate the challenges of avoiding Deadlock – a system state in which no progress is possible. Resource Starvation - A problem encountered in multitasking where a process is perpetually denied necessary resources. Without them the process can never finish its task, - Resource Starvation might occur independently if a particular philosopher is unable to acquire both forks because of a timing problem. Mutual Exclusion - Ensuring that no 2 concurrent processes are in their critical section at the same time. - A basic requirement in Concurrency Control to prevent race conditions. © Yash Mittal 3
  • 4. SOLUTIONS Resource Hierarchy Solution - Assigns a partial order to the resources (forks) - All resources will be requested in order & no 2 resources unrelated by order will ever be used by a single unit of work at the same time. - Resources are numbered 1-5 and each philosopher will always pick up the lower-numbered fork first and then the higher-numbered fork. - If 4 of 5 philosophers simultaneously pick up their ‘low fork’, only 1 ‘high fork’ will remain on the table. So the 5th philosopher will NOT be able to pick up any fork. → Also, only 1 philosopher will have access to the ‘high fork’  he will be able to eat using 2 forks - Not always practical if list of required resources is not completely known in advance. © Yash Mittal 4
  • 5. Arbitrator Solution - Guarantee that a philosopher can pick up only 2 solutions by introducing an arbitrator, Ex: waiter. → In order to pick up the forks, a philosopher must ask waiter’s permission → Waiter gives permission to only 1 philosopher at a time until he has picked up both his forks → Putting down a fork is always allowed. - Waiter is implemented as a mutex - a program object that allows multiple program threads to share the same resource, such as file access, but not simultaneously. © Yash Mittal 5
  • 6. Requirement Engineering Requirements are of 2 types: i. User ii. System a. Functional Requirements b. Non-Functional Requirements c. Domain Requirements Process of identification of requirements is called Requirement Engineering. Four phases 1. Requirement Discovery 2. Requirement Analysis 3. Requirement Validation 4. Requirement Management © Yash Mittal 6
  • 7. Requirement Discovery Phase Scenario – based Modelling Use Case Diagram – Actor : Philosophers – Use Cases : Thinking, Eating, Acquiring Resources (forks) Composition of Scenario [EATING] – Pre-Condition : Resources (forks) available – Normal Flow : Philosopher  2 forks available  Eating spaghetti  Finished  Put down forks  Thinking – Abnormal Flow : Philosopher is eating  Another philosopher avails resources (Deadlock) – Other Activity : Resource is not available  Philosopher thinks – Post-Condition : Free the resources (forks are available) © Yash Mittal 7
  • 8. Requirement Analysis Phase 3 Types of Modelling i. Class/Object Models ii. Flow Oriented Models iii. Behaviour Models Flow Oriented Models – Data Flow Diagrams DFD Level 0 © Yash Mittal 8
  • 9. DFD Level 1 © Yash Mittal 9
  • 10. Behaviour Modelling  State Diagram  Sequence Diagram © Yash Mittal 10
  • 11. THANK YOU © Yash Mittal 11