ECSE 427 Lecture Notes - Lecture 9: The Algorithm

60 views2 pages
ECSE 427 Tutorial #9 Notes
Alex Hale
- this tutorial outlines the functionality required for assignment #3
Assumptions
- in advance, we know the maximum number of resources each process will use
- when a process acquires resources, it will exit in a finite amount of time
Assignment Functions
main()
- gets user input, creates and runs threads
processSimulator()
- thread simulating a process (duh)
- gets a random resource request vector
- calls Bankers algorithm
- only gets resources if allocation is safe, and releases resources if its needs are met
bankersAlgorithm()
- (TODO by us) implementation of Bankers algorithm for deadlock avoidance
o We should implement it as described in the lecture slides
fault_simulator()
- thread that runs in the background, removing resources with the probability outlined in the
assignment specifications
deadlock_checker()
- checks if deadlock has occurred due to a resource fault
- the inputs to Bankers algorithm are specified by the user
o number of processes
o number of resources
o  = array of available resources
Indicates the maximum resources of each type the system has
o  = 2D array of maximum resources that each process is allowed to claim
- The algorithm needs other vectors/matrices that are not specified by the user
o  = array to keep track of how many resources each process is holding
initialized to 0
o  = array to keep track of how many resources each process needs to finish
o  = request vector of resources
In the assignment, this is simulated by a random value between 0 and the
number of resources needed to finish
- Quick explanation of Bankers algorithm and isSafe()
o Nothing to add other than the screenshots already in lecture notes, go see those
Unlock document

This preview shows half of the first page of the document.
Unlock all 2 pages and 3 million more documents.

Already have an account? Log in

Document Summary

Alex hale this tutorial outlines the functionality required for assignment #3. Assumptions in advance, we know the maximum number of resources each process will use. When a process acquires resources, it will exit in a finite amount of time. Assignment functions main() gets user input, creates and runs threads processsimulator() thread simulating a process (duh) gets a random resource request vector calls banker"s algorithm. The algorithm needs other vectors/matrices that are not specified by the user: number of processes, number of resources. In the assignment, this is simulated by a random value between 0 and the number of resources needed to finish initialized to 0. If not safe: (cid:1868)(cid:1870)(cid:1867)(cid:1855)(cid:1857)(cid:1871)(cid:1871)(cid:1845)(cid:1865)(cid:1873)(cid:1864)(cid:1853)(cid:1872)(cid:1867)(cid:1870)(cid:4666)(cid:4667) continuously calls (cid:1854)(cid:1853)(cid:1866)(cid:1863)(cid:1857)(cid:1870)(cid:1871)(cid:1864)(cid:1867)(cid:1870)(cid:1872) (cid:1865)(cid:4666)(cid:4667) until the resource allocation is safe. If safe: check if a process can terminate. If yes, free all resources held by that process. If no, sleep for three seconds, then make another request. Thread synchronization: we need to make sure that threads access the shared memory safely.

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents