A Simple Safe Programming syn..
Posted on 2004-09-09
The safe state algorithm is used by Operating Systems to avoid deadlock situations. The algorithm works by starting with a safe state, accepting a request for resources by a process, determining if the new state is safe, and then granting the request only if the new state is safe.
I am trying to write a program to implement the safe state algorithm under the following conditions. The program must handle up to 10 processes at any one time. There are four resource groups that can be requested. These are disk drives, tape drives, printers, and graphical plotters.
The current "state" of the system needs to be read into the program from a data file. It can be assumed that the current state is a safe one, however it will be simple enough for the program to verify this. Once the current state is read in, a new resource request can be read in from a data file or from the keyboard.
The program should accept this resource request and determine if the new state is also safe. The process of accepting new resource requests can be continued if desired.
The output from the program will be a display of the current state, the resource request entered, a message indicating whether the state is safe or not, and the sequence of processes that was used to verify the safe state. The output to the screen gotta be readable so i can determine what has occurred.
I need help on uncluding the code..it can either bein c or c++ as the compiler and runon MS-dos environment. PLease help me construct coding.
Thhank you in advance..