Connecting Tech Pros Worldwide Forums | Help | Site Map

Please Help Me To Write Code For Banker's Algoritm In Visual Basic 6.0

Newbie
 
Join Date: Jan 2007
Location: Arusha
Posts: 1
#1: Jan 14 '07
Please If any one of you know how to write code which will test the safe sequency i.e code that express Banker's algorithm
The pseudocode is as folows


 Step1: Let Work and Finish be vectors of length m and n, respectively.
Initialize:
Work := Available
Finish[i] := false for i = 1, 2, ..., n.
 Step2: Find an i such that both: (a unfinished process Pi whose future need for resources can be accommodated)
(a) Finish[i] = false
(b) Needi <= Work
If no such i exists,go to Step 4 else note Pi to be next in the safe sequence
 Step3:
Work := Work + Allocationi
Finish[i] := true
go to step 2.
 Step4: If Finish[i] = true for all i, then the system is in a safe state. print the safe sequence out
else declare state unsafe

Moderator
 
Join Date: Oct 2006
Location: Australia
Posts: 7,748
#2: Jan 15 '07

re: Please Help Me To Write Code For Banker's Algoritm In Visual Basic 6.0


I suspect you'd see a better response to this one in the general Techie Talk forum. It went straight over my head, but if someone can thrash out an algorithm, I'm sure I and others here can translate to VB easily enough.
Reply