aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominic Matarese <dominicmatarese@gmail.com>2023-01-30 18:28:22 -0500
committerDominic Matarese <dominicmatarese@gmail.com>2023-01-30 18:28:22 -0500
commita563fd4ff54072755bc590639d615a11af5663ec (patch)
tree98a86dfc3c406ad5af5328ea035e51d4001a2f2e
parent4b51773c1a9ab7fb54206a2e63ff7bdb7825ce29 (diff)
added more comprehensive documentationHEADmaster
-rw-r--r--readme.md52
1 files changed, 50 insertions, 2 deletions
diff --git a/readme.md b/readme.md
index 207ebf3..bcd50f8 100644
--- a/readme.md
+++ b/readme.md
@@ -1,2 +1,50 @@
-This is an algorithm used to determine if an operating system is in a "safe state" i.e no deadlocks possible.
-A deadlock can occur in a system if each process is waiting on a resource from another process to complete, and no process can relinquish resources until it is completed.
+
+# Banker's Algorithm
+
+This is a Java implementation of the Banker's Algorithm, an algorithm used to determine if an operating system is in a "safe state" with no deadlocks possible. The algorithm is used to prevent deadlocks by ensuring that the system will always have a safe sequence of processes to execute. It does this by checking if the system's current state is safe or not by using the concept of resource allocation graph and the safety algorithm.
+
+## Features
+
+- Detection of safe state
+- Prevention of deadlocks
+
+## Dependencies
+
+- Java Development Kit (JDK)
+- IDE (Integrated Development Environment) or a text editor
+
+## Usage
+Compile the program
+`javac Main.java`
+
+Then run it
+`java Main`
+
+2. The program will prompt you to enter the number of processes and the number of resources.
+3. Then it will prompt you to enter the maximum resources each process can have and the resources already allocated to each process.
+4. The program will then use the Banker's Algorithm to check if the system is in a safe state or not and display the safe sequence of processes if the system is in a safe state.
+
+## Note
+
+- The program uses the Banker's Algorithm to prevent deadlocks and check for safe states, this algorithm is widely used in operating systems.
+- The program is a simulation of the algorithm, the user needs to enter the inputs manually, it can be modified to read inputs from a file or a database.
+- The program uses the concept of resource allocation graph and the safety algorithm, it might be helpful to understand these concepts before using the program.
+
+Here is an example of a resource allocation graph in ASCII:
+
+
+| | A | B | C | D |
+|----|------|------|------|------|
+| R1 | [3] | [2] | [2] | [1] |
+| R2 | [2] | [1] | [1] | [2] |
+| R3 | [1] | [3] | [3] | [3] |
+
+In this example, the graph represents a system with 4 processes (A, B, C, and D) and 3 resources (R1, R2, and R3). Each cell in the graph represents the number of units of a resource that a process is currently holding. In this case, process A is holding 3 units of resource R1, 2 units of resource R2, and 1 unit of resource R3. Similarly, process B is holding 2 units of resource R1, 1 unit of resource R2, and 3 units of resource R3. The resource allocation graph is used to check the system's state and check if the system is in a safe state or not by using the Banker's Algorithm.
+
+## License
+
+This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.