SlideShare a Scribd company logo
Team Project
Presentation
The implementation of Banker’s algorithm, data structure
and parser
Ikwhan Chang (010754107)

Group #10
2-Dec 2016
1
INDEX
• The Definition of Deadlock and Banker’s Algorithm
• Deadlock
• Safe State & Unsafe State
• Banker’s algorithm
• Implementation
• Approach
• UML & Actor model
• Program Design
• Demo
2
Deadlock
3
• A set of blocked processes each holding a resource and waiting to acquire a resource held by another
process in the set.
Four Conditions for Deadlock
1) Mutex Exclusion: each resource can be assigned or used only one process at a request
time
2) Hold and Wait:The process can capture the currently needed resources and request
the new resources needed.
3) No Preemption: Resources already allocated are not forcibly deprived by other
processes.
4) Circular Wait:This situation is intertwined in the shape of a circle.
4
Deadlock Prevention Vs. Avoidance
Deadlock Prevention
• Preventing deadlocks by constraining how requests for resources can be made in the system and how
they are handled (system design).
• The goal is to ensure that at least one of the necessary conditions for deadlock can never hold.
Deadlock Avoidance - Banker’s algorithm
• The system dynamically considers every request and decides whether it is safe to grant it at this point,
• The system requires additional a priori information regarding the overall potential use of each resource for
each process.
• Allows more concurrency.
• => Similar to the difference between a traffic light and a police officer directing traffic.
5
Safe State vs Unsafe State
Safe state
• Status in which the task can be completed
• Safety Sequence:The order in which all processes can complete tasks using available resources
• => If you find the safety sequence, then we can call it is Safe
Unsafe State
• The state that a deadlock can occur
• We cannot find the Safety Sequence
• Deadlock does not occur in safe state, but it can change from safe state to unsafe state.
• The situation where you do not switch from unsafe to deadlock is partial return, if you return in full and go from
unsafe to safe.
• If the next state is unsafe, deny resource allocation
6
Banker’s algorithm - Definition
Suppose we know the “worst case” resource needs of processes in advance
• A bit like knowing the credit limit on your credit cards. (This is why they call it the Banker’s Algorithm)
Observation: Suppose we just give some process ALL the resources it could need…
• Then it will execute to completion.
• After which it will give back the resources.
As a result:
• A process pre-declares its worst-case needs
• Then it asks for what it “really” needs, a little at a time
• The algorithm decides when to grant requests
It delays a request unless:
• It can find a sequence of processes such that it could grant their outstanding need.
• So they would terminate. letting it collect their resources and in this way it can execute everything to completion
7
Banker’s algorithm - Notation
* N: the number of processes on the system
* M: the number of resources present in the system
- Available [1: m]: Indicate which resource i is
- Max [1: n, 1: m]: Expression of the maximum number of resources of type j of process i
- Allocation [1: n, 1: m]: Indicates whether process i has received a resource of type j
- Need [1: n, 1: m]: Max - Allocation. Express how many more can be allocated in the future
-Vectors X,Y
- Work array: an array containing the intermediate result of a resource
- Finish array: a boolean array indicating which process has terminated
8
Banker’s algorithm - Safety Check
Step 1. Assign the resources currently available for work. Finish Set all values of array to false (which means that no processes have
finished yet)
Step 2. Find a process i that does not finish its current run and can satisfy all of the resources it needs the most.
Step 3.Terminate the process and return the resource to finish.

Step 4.When all finish [] entry values are true, the algorithm is ended
How to perform a resource grant using Safety Check
Step 1. Record the newly requested request of each process in the request array
Step 2. If a request in a process requests more than Maximum, it will not accept the request
Step 3. If the condition is less than the maximum value, once you have performed the safety check algorithm
=>The banker's algorithm is implemented in safety and performs deadlock avoidance.
=>There are situations in which a process needs to manage a maximum request for each type, making expensive decisions to perform
and deadlock avoidance.
9
Banker’s algorithm - Example
10
5 processes P0 through P4; 3 resource types A (10 instances), B (5instances), and C (7 instances).
Snapshot at timeT0:
Allocation Max Available
A B C A B C A B C
P0 0 1 0 7 5 3 3 3 2
P1 2 0 0 3 2 2
P2 3 0 2 9 0 2
P3 2 1 1 2 2 2
P4 0 0 2 4 3 3
Banker’s algorithm - Example
11
The content of the matrix. Need is defined to be Max – Allocation.
Need
A B C
P0 7 4 3
P1 1 2 2
P2 6 0 0
P3 0 1 1
P4 4 3 1
The system is in a safe state since the sequence < P1, P3, P4, P2, P0> satisfies safety criteria.
Approach
Problem
• In our project, we implemented the parser of banker’s algorithm. Since banker’s algorithm is quite simple to implement,
we realized that it is more important to define the data structure of banker’s algorithm as well as parse of it.Thus, we
are focusing on the implementation of parser and data structure.
Development Environment
•Language: C
•Compiler: gcc with c++ 4.2.1 on Apple LLVM v. 8.0.0 target for x86_64-apple-darwin16.3.0
•IDE: Xcode
12
Approach
1) Defined a banker’s information structure
#define A 65
#define MAX_RESOURCE 100
#define MAX_PROCESS 100
#define MAX_RESOURCE_NAME_LEN 40
typedef struct _banker_info
{
char resource_name[MAX_RESOURCE]
[MAX_RESOURCE_NAME_LEN + 1];
int available[MAX_RESOURCE];
int instance_count[MAX_RESOURCE];
int allocation[MAX_PROCESS][MAX_RESOURCE];
int max[MAX_PROCESS][MAX_RESOURCE];
int need[MAX_PROCESS][MAX_RESOURCE];
int process_count;
int resource_count;
int sequence[MAX_PROCESS];
int sequence_count;
int is_prepared;
} banker_info;
13
2) Implemented a scanner module to separate
tokens from files.
Token Types
• ENDFILE: the end of file, 
• ERROR: scan error
• ID:Alphabet exists more than one
• NUM: Decimal exists more than one
• COLON:“:” 
Approach
3) Program command
• load [file_name]: Read Banker’s
information from file
• view: Display the information of Banker
• quit: Exit the program
14
4) Error type for reading the input
• When the allocation value of the process is
larger than the available value of the resource
• When the allocation value of the process is
larger than its max value
• When negative value is input to all values
• When unexpected input is found in the file
format
User Scenario Read information from file
15
User Scenario Display the result
16
Program Design
17
Demo 18
Thanks! 19
Design by Matthew, Chang
http://matthewlab.com

More Related Content

PDF
Naive Bayes Classifier
Yiqun Hu
 
PPTX
PCA and LDA in machine learning
Akhilesh Joshi
 
PPTX
Transport layer protocols : Simple Protocol , Stop and Wait Protocol , Go-Bac...
Kongu Engineering College, Perundurai, Erode
 
PPTX
DDoS ATTACKS
Anil Antony
 
PPTX
Web Application Vulnerabilities
Preetish Panda
 
PDF
Virtualization Basics
SrikantMishra12
 
PDF
Token, Pattern and Lexeme
A. S. M. Shafi
 
Naive Bayes Classifier
Yiqun Hu
 
PCA and LDA in machine learning
Akhilesh Joshi
 
Transport layer protocols : Simple Protocol , Stop and Wait Protocol , Go-Bac...
Kongu Engineering College, Perundurai, Erode
 
DDoS ATTACKS
Anil Antony
 
Web Application Vulnerabilities
Preetish Panda
 
Virtualization Basics
SrikantMishra12
 
Token, Pattern and Lexeme
A. S. M. Shafi
 

What's hot (20)

PPT
Unit 4
Ravi Kumar
 
PPT
Lamport’s algorithm for mutual exclusion
Neelamani Samal
 
PPTX
Lecture 10 intruders
rajakhurram
 
PPTX
SPADE -
Monica Dagadita
 
PPTX
Understanding Cross-site Request Forgery
Daniel Miessler
 
PDF
Vc dimension in Machine Learning
VARUN KUMAR
 
PPT
Intruders
techn
 
ODP
NAIVE BAYES CLASSIFIER
Knoldus Inc.
 
PDF
Cross site scripting (xss) attacks issues and defense - by sandeep kumbhar
Sandeep Kumbhar
 
PPT
DDoS Attack PPT by Nitin Bisht
Nitin Bisht
 
PPTX
Naive bayes
Ashraf Uddin
 
PPTX
Join ordering in fragment queries
Ifzalhussainkhan
 
PPTX
SQL INJECTION
Anoop T
 
PPT
Comet Cloud
pradeepas7
 
PDF
CS8791 Cloud Computing - Question Bank
pkaviya
 
PPTX
Local beam search example
Megha Sharma
 
PPTX
Security and privacy in cloud computing.pptx
TRSrinidi
 
PPT
Iterative deepening search
Ashis Kumar Chanda
 
PDF
Fraud detection with Machine Learning
Scaleway
 
Unit 4
Ravi Kumar
 
Lamport’s algorithm for mutual exclusion
Neelamani Samal
 
Lecture 10 intruders
rajakhurram
 
SPADE -
Monica Dagadita
 
Understanding Cross-site Request Forgery
Daniel Miessler
 
Vc dimension in Machine Learning
VARUN KUMAR
 
Intruders
techn
 
NAIVE BAYES CLASSIFIER
Knoldus Inc.
 
Cross site scripting (xss) attacks issues and defense - by sandeep kumbhar
Sandeep Kumbhar
 
DDoS Attack PPT by Nitin Bisht
Nitin Bisht
 
Naive bayes
Ashraf Uddin
 
Join ordering in fragment queries
Ifzalhussainkhan
 
SQL INJECTION
Anoop T
 
Comet Cloud
pradeepas7
 
CS8791 Cloud Computing - Question Bank
pkaviya
 
Local beam search example
Megha Sharma
 
Security and privacy in cloud computing.pptx
TRSrinidi
 
Iterative deepening search
Ashis Kumar Chanda
 
Fraud detection with Machine Learning
Scaleway
 
Ad

Similar to The implementation of Banker's algorithm, data structure and its parser (20)

PPTX
Bankers algorithm pbl project based ppt.
ansuljoshi8456
 
PPTX
Deadlock
Mahershi ACT
 
PDF
Deadlock
Farhat Shaikh
 
PPTX
Deadlock Slides
sehrishishaq1
 
PPTX
hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
HenryWongChengyong1
 
PPTX
7308346-Deadlock.pptx
sheraz7288
 
PDF
Deadlocks Part- II.pdf
Harika Pudugosula
 
PPTX
Deadlock and memory management -- Operating System
EktaVaswani2
 
PPTX
OS - Unit 3 Deadlock (Bankers Algorithm).pptx
GovindJha93
 
PPTX
Deadlock Algorithms 3.pptx
AbuBakkarShayan
 
PDF
Unit 3 part 2(DEADLOCK)
WajeehaBaig
 
PPTX
understanding deadlock in operating systems
Prabu P
 
PPTX
Deadlocks and Deadlock Detection Other Issues
Guna Dhondwad
 
PPTX
deadlock in operating system in osss.pptx
nagasair12345
 
PPTX
deadlock in operating system ( os ).pptx
nagasair12345
 
PDF
Deadlock in Distributed Systems
Pritom Saha Akash
 
PDF
OS-Part-06.pdf
NguyenTienDungK17HL
 
PPTX
Module 3 Deadlocks.pptx
shreesha16
 
PPT
DeadlockMar21.ppt
hetrathod001
 
PDF
Implementation of Banker’s Algorithm Using Dynamic Modified Approach
rahulmonikasharma
 
Bankers algorithm pbl project based ppt.
ansuljoshi8456
 
Deadlock
Mahershi ACT
 
Deadlock
Farhat Shaikh
 
Deadlock Slides
sehrishishaq1
 
hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
HenryWongChengyong1
 
7308346-Deadlock.pptx
sheraz7288
 
Deadlocks Part- II.pdf
Harika Pudugosula
 
Deadlock and memory management -- Operating System
EktaVaswani2
 
OS - Unit 3 Deadlock (Bankers Algorithm).pptx
GovindJha93
 
Deadlock Algorithms 3.pptx
AbuBakkarShayan
 
Unit 3 part 2(DEADLOCK)
WajeehaBaig
 
understanding deadlock in operating systems
Prabu P
 
Deadlocks and Deadlock Detection Other Issues
Guna Dhondwad
 
deadlock in operating system in osss.pptx
nagasair12345
 
deadlock in operating system ( os ).pptx
nagasair12345
 
Deadlock in Distributed Systems
Pritom Saha Akash
 
OS-Part-06.pdf
NguyenTienDungK17HL
 
Module 3 Deadlocks.pptx
shreesha16
 
DeadlockMar21.ppt
hetrathod001
 
Implementation of Banker’s Algorithm Using Dynamic Modified Approach
rahulmonikasharma
 
Ad

More from Matthew Chang (20)

DOCX
Research and Analysis of SSH
Matthew Chang
 
PPTX
Digital Certified Mail (PPT)
Matthew Chang
 
PDF
Digital Certified Mail
Matthew Chang
 
PDF
Twitter Trend Analyzer
Matthew Chang
 
PDF
Image Compression Storage Policy for Openstack Swift
Matthew Chang
 
PDF
Urhyme introduction
Matthew Chang
 
PPTX
SDN Project PPT
Matthew Chang
 
PDF
Analyze of Tumblr.com
Matthew Chang
 
PPTX
Project Avalon
Matthew Chang
 
PDF
A new interface between smart device and web using html5 web socket and qr code
Matthew Chang
 
PDF
Logic Circuit Project Final Presentation
Matthew Chang
 
PDF
Programming Language Final PPT
Matthew Chang
 
PDF
Profile_ Ikwhan chang
Matthew Chang
 
PDF
모바일 앱 개발 최종 발표 Proposal
Matthew Chang
 
PDF
Capstone Project Final Presentation
Matthew Chang
 
PDF
Project Avalon Online(Game) Final Report
Matthew Chang
 
PDF
Project NGX - Proposal
Matthew Chang
 
PDF
Report : Android Simple Bug Catch Game(Korean)
Matthew Chang
 
PPTX
Capstone Project Last Demonstration
Matthew Chang
 
PDF
Db설계 프로젝트 1조 _중간제출
Matthew Chang
 
Research and Analysis of SSH
Matthew Chang
 
Digital Certified Mail (PPT)
Matthew Chang
 
Digital Certified Mail
Matthew Chang
 
Twitter Trend Analyzer
Matthew Chang
 
Image Compression Storage Policy for Openstack Swift
Matthew Chang
 
Urhyme introduction
Matthew Chang
 
SDN Project PPT
Matthew Chang
 
Analyze of Tumblr.com
Matthew Chang
 
Project Avalon
Matthew Chang
 
A new interface between smart device and web using html5 web socket and qr code
Matthew Chang
 
Logic Circuit Project Final Presentation
Matthew Chang
 
Programming Language Final PPT
Matthew Chang
 
Profile_ Ikwhan chang
Matthew Chang
 
모바일 앱 개발 최종 발표 Proposal
Matthew Chang
 
Capstone Project Final Presentation
Matthew Chang
 
Project Avalon Online(Game) Final Report
Matthew Chang
 
Project NGX - Proposal
Matthew Chang
 
Report : Android Simple Bug Catch Game(Korean)
Matthew Chang
 
Capstone Project Last Demonstration
Matthew Chang
 
Db설계 프로젝트 1조 _중간제출
Matthew Chang
 

Recently uploaded (20)

PDF
Chad Ayach - A Versatile Aerospace Professional
Chad Ayach
 
PDF
20ME702-Mechatronics-UNIT-1,UNIT-2,UNIT-3,UNIT-4,UNIT-5, 2025-2026
Mohanumar S
 
PPTX
Civil Engineering Practices_BY Sh.JP Mishra 23.09.pptx
bineetmishra1990
 
PDF
Zero Carbon Building Performance standard
BassemOsman1
 
PDF
Unit I Part II.pdf : Security Fundamentals
Dr. Madhuri Jawale
 
PDF
LEAP-1B presedntation xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
hatem173148
 
PPTX
Module2 Data Base Design- ER and NF.pptx
gomathisankariv2
 
PDF
settlement FOR FOUNDATION ENGINEERS.pdf
Endalkazene
 
PPTX
MT Chapter 1.pptx- Magnetic particle testing
ABCAnyBodyCanRelax
 
PDF
EVS+PRESENTATIONS EVS+PRESENTATIONS like
saiyedaqib429
 
PDF
Cryptography and Information :Security Fundamentals
Dr. Madhuri Jawale
 
PDF
Biodegradable Plastics: Innovations and Market Potential (www.kiu.ac.ug)
publication11
 
PDF
2010_Book_EnvironmentalBioengineering (1).pdf
EmilianoRodriguezTll
 
PPTX
22PCOAM21 Session 2 Understanding Data Source.pptx
Guru Nanak Technical Institutions
 
PDF
Advanced LangChain & RAG: Building a Financial AI Assistant with Real-Time Data
Soufiane Sejjari
 
PDF
Top 10 read articles In Managing Information Technology.pdf
IJMIT JOURNAL
 
PDF
Zero carbon Building Design Guidelines V4
BassemOsman1
 
DOCX
SAR - EEEfdfdsdasdsdasdasdasdasdasdasdasda.docx
Kanimozhi676285
 
PDF
Traditional Exams vs Continuous Assessment in Boarding Schools.pdf
The Asian School
 
PDF
dse_final_merit_2025_26 gtgfffffcjjjuuyy
rushabhjain127
 
Chad Ayach - A Versatile Aerospace Professional
Chad Ayach
 
20ME702-Mechatronics-UNIT-1,UNIT-2,UNIT-3,UNIT-4,UNIT-5, 2025-2026
Mohanumar S
 
Civil Engineering Practices_BY Sh.JP Mishra 23.09.pptx
bineetmishra1990
 
Zero Carbon Building Performance standard
BassemOsman1
 
Unit I Part II.pdf : Security Fundamentals
Dr. Madhuri Jawale
 
LEAP-1B presedntation xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
hatem173148
 
Module2 Data Base Design- ER and NF.pptx
gomathisankariv2
 
settlement FOR FOUNDATION ENGINEERS.pdf
Endalkazene
 
MT Chapter 1.pptx- Magnetic particle testing
ABCAnyBodyCanRelax
 
EVS+PRESENTATIONS EVS+PRESENTATIONS like
saiyedaqib429
 
Cryptography and Information :Security Fundamentals
Dr. Madhuri Jawale
 
Biodegradable Plastics: Innovations and Market Potential (www.kiu.ac.ug)
publication11
 
2010_Book_EnvironmentalBioengineering (1).pdf
EmilianoRodriguezTll
 
22PCOAM21 Session 2 Understanding Data Source.pptx
Guru Nanak Technical Institutions
 
Advanced LangChain & RAG: Building a Financial AI Assistant with Real-Time Data
Soufiane Sejjari
 
Top 10 read articles In Managing Information Technology.pdf
IJMIT JOURNAL
 
Zero carbon Building Design Guidelines V4
BassemOsman1
 
SAR - EEEfdfdsdasdsdasdasdasdasdasdasdasda.docx
Kanimozhi676285
 
Traditional Exams vs Continuous Assessment in Boarding Schools.pdf
The Asian School
 
dse_final_merit_2025_26 gtgfffffcjjjuuyy
rushabhjain127
 

The implementation of Banker's algorithm, data structure and its parser

  • 1. Team Project Presentation The implementation of Banker’s algorithm, data structure and parser Ikwhan Chang (010754107)
 Group #10 2-Dec 2016 1
  • 2. INDEX • The Definition of Deadlock and Banker’s Algorithm • Deadlock • Safe State & Unsafe State • Banker’s algorithm • Implementation • Approach • UML & Actor model • Program Design • Demo 2
  • 3. Deadlock 3 • A set of blocked processes each holding a resource and waiting to acquire a resource held by another process in the set.
  • 4. Four Conditions for Deadlock 1) Mutex Exclusion: each resource can be assigned or used only one process at a request time 2) Hold and Wait:The process can capture the currently needed resources and request the new resources needed. 3) No Preemption: Resources already allocated are not forcibly deprived by other processes. 4) Circular Wait:This situation is intertwined in the shape of a circle. 4
  • 5. Deadlock Prevention Vs. Avoidance Deadlock Prevention • Preventing deadlocks by constraining how requests for resources can be made in the system and how they are handled (system design). • The goal is to ensure that at least one of the necessary conditions for deadlock can never hold. Deadlock Avoidance - Banker’s algorithm • The system dynamically considers every request and decides whether it is safe to grant it at this point, • The system requires additional a priori information regarding the overall potential use of each resource for each process. • Allows more concurrency. • => Similar to the difference between a traffic light and a police officer directing traffic. 5
  • 6. Safe State vs Unsafe State Safe state • Status in which the task can be completed • Safety Sequence:The order in which all processes can complete tasks using available resources • => If you find the safety sequence, then we can call it is Safe Unsafe State • The state that a deadlock can occur • We cannot find the Safety Sequence • Deadlock does not occur in safe state, but it can change from safe state to unsafe state. • The situation where you do not switch from unsafe to deadlock is partial return, if you return in full and go from unsafe to safe. • If the next state is unsafe, deny resource allocation 6
  • 7. Banker’s algorithm - Definition Suppose we know the “worst case” resource needs of processes in advance • A bit like knowing the credit limit on your credit cards. (This is why they call it the Banker’s Algorithm) Observation: Suppose we just give some process ALL the resources it could need… • Then it will execute to completion. • After which it will give back the resources. As a result: • A process pre-declares its worst-case needs • Then it asks for what it “really” needs, a little at a time • The algorithm decides when to grant requests It delays a request unless: • It can find a sequence of processes such that it could grant their outstanding need. • So they would terminate. letting it collect their resources and in this way it can execute everything to completion 7
  • 8. Banker’s algorithm - Notation * N: the number of processes on the system * M: the number of resources present in the system - Available [1: m]: Indicate which resource i is - Max [1: n, 1: m]: Expression of the maximum number of resources of type j of process i - Allocation [1: n, 1: m]: Indicates whether process i has received a resource of type j - Need [1: n, 1: m]: Max - Allocation. Express how many more can be allocated in the future -Vectors X,Y - Work array: an array containing the intermediate result of a resource - Finish array: a boolean array indicating which process has terminated 8
  • 9. Banker’s algorithm - Safety Check Step 1. Assign the resources currently available for work. Finish Set all values of array to false (which means that no processes have finished yet) Step 2. Find a process i that does not finish its current run and can satisfy all of the resources it needs the most. Step 3.Terminate the process and return the resource to finish.
 Step 4.When all finish [] entry values are true, the algorithm is ended How to perform a resource grant using Safety Check Step 1. Record the newly requested request of each process in the request array Step 2. If a request in a process requests more than Maximum, it will not accept the request Step 3. If the condition is less than the maximum value, once you have performed the safety check algorithm =>The banker's algorithm is implemented in safety and performs deadlock avoidance. =>There are situations in which a process needs to manage a maximum request for each type, making expensive decisions to perform and deadlock avoidance. 9
  • 10. Banker’s algorithm - Example 10 5 processes P0 through P4; 3 resource types A (10 instances), B (5instances), and C (7 instances). Snapshot at timeT0: Allocation Max Available A B C A B C A B C P0 0 1 0 7 5 3 3 3 2 P1 2 0 0 3 2 2 P2 3 0 2 9 0 2 P3 2 1 1 2 2 2 P4 0 0 2 4 3 3
  • 11. Banker’s algorithm - Example 11 The content of the matrix. Need is defined to be Max – Allocation. Need A B C P0 7 4 3 P1 1 2 2 P2 6 0 0 P3 0 1 1 P4 4 3 1 The system is in a safe state since the sequence < P1, P3, P4, P2, P0> satisfies safety criteria.
  • 12. Approach Problem • In our project, we implemented the parser of banker’s algorithm. Since banker’s algorithm is quite simple to implement, we realized that it is more important to define the data structure of banker’s algorithm as well as parse of it.Thus, we are focusing on the implementation of parser and data structure. Development Environment •Language: C •Compiler: gcc with c++ 4.2.1 on Apple LLVM v. 8.0.0 target for x86_64-apple-darwin16.3.0 •IDE: Xcode 12
  • 13. Approach 1) Defined a banker’s information structure #define A 65 #define MAX_RESOURCE 100 #define MAX_PROCESS 100 #define MAX_RESOURCE_NAME_LEN 40 typedef struct _banker_info { char resource_name[MAX_RESOURCE] [MAX_RESOURCE_NAME_LEN + 1]; int available[MAX_RESOURCE]; int instance_count[MAX_RESOURCE]; int allocation[MAX_PROCESS][MAX_RESOURCE]; int max[MAX_PROCESS][MAX_RESOURCE]; int need[MAX_PROCESS][MAX_RESOURCE]; int process_count; int resource_count; int sequence[MAX_PROCESS]; int sequence_count; int is_prepared; } banker_info; 13 2) Implemented a scanner module to separate tokens from files. Token Types • ENDFILE: the end of file,  • ERROR: scan error • ID:Alphabet exists more than one • NUM: Decimal exists more than one • COLON:“:” 
  • 14. Approach 3) Program command • load [file_name]: Read Banker’s information from file • view: Display the information of Banker • quit: Exit the program 14 4) Error type for reading the input • When the allocation value of the process is larger than the available value of the resource • When the allocation value of the process is larger than its max value • When negative value is input to all values • When unexpected input is found in the file format
  • 15. User Scenario Read information from file 15
  • 16. User Scenario Display the result 16
  • 19. Thanks! 19 Design by Matthew, Chang http://matthewlab.com