Homework 4 – Banker’s algorithm Implement the Banker's algorithm for deadlock avoidance, with a given set of N processes (N

1 answer below »
n/a


Homework 4 – Banker’s algorithm Implement the Banker's algorithm for deadlock avoidance, with a given set of N processes (N<10, processes="" are="" p1,="" p2,="" …,="" pn)="" and="" m="" resource="" types=""><10, resources are r1, r2, …, rm). use java or c/c++ for the implementation, with a simple interface, where the user only supplies the name of the input file (text file, say “input.txt”). the program reads all the necessary input data from that file. you are free to choose the format of the input file, just make sure it contains all the necessary data. the input data and the result of the algorithm must be displayed on the screen. the pseudo code for the greedy version for the banker’s algorithm can be found in this module’s commentary. we know that this algorithm only finds one solution (safe sequence of processes) assuming there is one; otherwise reports there is no solution. you must adjust this algorithm to find exactly two solutions instead of just one (assuming of course there are at least two solutions). if the algorithm only has one solution this must be reported as such and the single solution must be displayed. to resume, there are only three possible scenarios, for a correct input file: 1. there is no solution (no safe sequence). the program must report there is no solution. 2. there is exactly one solution (safe sequence). the program must report there is exactly one solution. the solution must be displayed on screen. 3. there are two or more solutions (safe sequences). the program must find exactly two solutions. the solutions must be displayed on screen. if there are more than two solutions, it doesn’t matter which ones are found, as long as they are exactly two. note 1: the solution must be based on the greedy version for the banker’s algorithm; in particular, using an approach for finding all solutions and then keeping and reporting just two of them is not allowed. note 2: the input file may be incorrect, for various reasons. this must be checked and reported by your program before any attempt of finding a solution. hints: - the input files should start with n and m, then the necessary matrices - work on your own computer or online using https://replit.com deliverables: 1. the source code for your program, stored in a text file 2. one incorrect input file, “input0.txt” and one or more screenshots showing the results of your program for this incorrect input. 3. three input files, “input1.txt” (n=4, m=3), “input2.txt” (n=4, m=3), “input3.txt” (n=4, m=3). please choose the input data in such a way that the first input has no solution, the second input has exactly one solution and the third input has at least two solutions. 4. three screenshots showing the final results of your program’s execution for these three input files. 5. store the screenshots in graphic files of your preferred format(“.png” or ”.gif” or “.pdf”, etc.). https://replit.com/ resources="" are="" r1,="" r2,="" …,="" rm).="" use="" java="" or="" c/c++="" for="" the="" implementation,="" with="" a="" simple="" interface,="" where="" the="" user="" only="" supplies="" the="" name="" of="" the="" input="" file="" (text="" file,="" say="" “input.txt”).="" the="" program="" reads="" all="" the="" necessary="" input="" data="" from="" that="" file.="" you="" are="" free="" to="" choose="" the="" format="" of="" the="" input="" file,="" just="" make="" sure="" it="" contains="" all="" the="" necessary="" data.="" the="" input="" data="" and="" the="" result="" of="" the="" algorithm="" must="" be="" displayed="" on="" the="" screen.="" the="" pseudo="" code="" for="" the="" greedy="" version="" for="" the="" banker’s="" algorithm="" can="" be="" found="" in="" this="" module’s="" commentary.="" we="" know="" that="" this="" algorithm="" only="" finds="" one="" solution="" (safe="" sequence="" of="" processes)="" assuming="" there="" is="" one;="" otherwise="" reports="" there="" is="" no="" solution.="" you="" must="" adjust="" this="" algorithm="" to="" find="" exactly="" two="" solutions="" instead="" of="" just="" one="" (assuming="" of="" course="" there="" are="" at="" least="" two="" solutions).="" if="" the="" algorithm="" only="" has="" one="" solution="" this="" must="" be="" reported="" as="" such="" and="" the="" single="" solution="" must="" be="" displayed.="" to="" resume,="" there="" are="" only="" three="" possible="" scenarios,="" for="" a="" correct="" input="" file:="" 1.="" there="" is="" no="" solution="" (no="" safe="" sequence).="" the="" program="" must="" report="" there="" is="" no="" solution.="" 2.="" there="" is="" exactly="" one="" solution="" (safe="" sequence).="" the="" program="" must="" report="" there="" is="" exactly="" one="" solution.="" the="" solution="" must="" be="" displayed="" on="" screen.="" 3.="" there="" are="" two="" or="" more="" solutions="" (safe="" sequences).="" the="" program="" must="" find="" exactly="" two="" solutions.="" the="" solutions="" must="" be="" displayed="" on="" screen.="" if="" there="" are="" more="" than="" two="" solutions,="" it="" doesn’t="" matter="" which="" ones="" are="" found,="" as="" long="" as="" they="" are="" exactly="" two.="" note="" 1:="" the="" solution="" must="" be="" based="" on="" the="" greedy="" version="" for="" the="" banker’s="" algorithm;="" in="" particular,="" using="" an="" approach="" for="" finding="" all="" solutions="" and="" then="" keeping="" and="" reporting="" just="" two="" of="" them="" is="" not="" allowed.="" note="" 2:="" the="" input="" file="" may="" be="" incorrect,="" for="" various="" reasons.="" this="" must="" be="" checked="" and="" reported="" by="" your="" program="" before="" any="" attempt="" of="" finding="" a="" solution.="" hints:="" -="" the="" input="" files="" should="" start="" with="" n="" and="" m,="" then="" the="" necessary="" matrices="" -="" work="" on="" your="" own="" computer="" or="" online="" using="" https://replit.com="" deliverables:="" 1.="" the="" source="" code="" for="" your="" program,="" stored="" in="" a="" text="" file="" 2.="" one="" incorrect="" input="" file,="" “input0.txt”="" and="" one="" or="" more="" screenshots="" showing="" the="" results="" of="" your="" program="" for="" this="" incorrect="" input.="" 3.="" three="" input="" files,="" “input1.txt”="" (n="4," m="3)," “input2.txt”="" (n="4," m="3)," “input3.txt”="" (n="4," m="3)." please="" choose="" the="" input="" data="" in="" such="" a="" way="" that="" the="" first="" input="" has="" no="" solution,="" the="" second="" input="" has="" exactly="" one="" solution="" and="" the="" third="" input="" has="" at="" least="" two="" solutions.="" 4.="" three="" screenshots="" showing="" the="" final="" results="" of="" your="" program’s="" execution="" for="" these="" three="" input="" files.="" 5.="" store="" the="" screenshots="" in="" graphic="" files="" of="" your="" preferred="" format(“.png”="" or="" ”.gif”="" or="" “.pdf”,="" etc.).="">
Answered 1 days AfterFeb 06, 2023

Answer To: Homework 4 – Banker’s algorithm Implement the Banker's algorithm for deadlock avoidance, with a...

Sathishkumar answered on Feb 08 2023
32 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here