Banker's algorithm is a resource allocation and deadlock avoidance method that simulates allocation for predefined maximum feasible quantities of all resources in order to test for safety.
--> C Programming Language
--> GCC Complier for C
--> Windows Subsystem for Linux
Compile the program using GCC. When running, pass a list of space-delimited integers as arguments. The value of the number represents the number of available resources of that type of resource. Edit sample4_in.txt to change the customers. Each line in the file represents a thread, and the comma-delimited values represent the amount of each type of resource that the thread needs.
- Request resources:
Requests an allocation of resources to a thread/customer, succeeds if resources are currently available and system remains safe after processing request, fails otherwise.
- Release resources:
Releases resources currently being used by a thread/customer and makes them available again, fails if thread has not been allocated those resources.
- Status:
Displays the status of the system including available resources, and maximum, allocated, and needed resources for each thread/customer.
- Run:
Determines if there is a safe sequence for the threads/customers and executes the sequence if possible.
- Exit:
Terminates the program.
Function | Kelvin | Nish |
---|---|---|
main | X | |
run_program | X | X |
load_available_resoures | X | |
load_customer_resources | X | X |
display_status | X | |
request_resources | X | X |
release_resources | X | X |
run_resources | X | X |
is_safe | X | X |
handle_request | X | X |
See an example test case here.
--> Kelvin Kellner
--> Nishant Tewari
--> GeeksforGeeks - Banker’s Algorithm in Operating System
This project is licensed under the MIT License which is located here.