GithubHelp home page GithubHelp logo

bankers_algorithm's Introduction

Operating Systems Project 2

Project 2 deals with deadlock avoidance using the banker's algorithm.

  • David J Tinley
  • 11/30/2023

Overview

For this project we had to consider a system with 5 processes (P_0, P_1, P_2, P_3, and P_4). The system also has 3 resources of types A, B, and C. From my understanding we then had to create a text file that would read in the allocated types and quantity assigned to each process. So the text file would essentially represent a 2D array, for example:
{
{0, 1, 0},
{1, 3, 2},
{2, 1, 0},
{2, 1, 2},
{1, 1, 0},
}
I assumed that we did not want to change maximum values that were described in the assignment description. I had to get some help with using and trying to understand the implementation of the bankers algorithm. I was able to find a resource at https://www.geeksforgeeks.org/bankers-algorithm-in-operating-system-2/. The example and description from this site used the same table as our assignment so that helped a lot.

Features

The main feature that was added was the ability to read in from a file and assign the read in integers the program. Like I mentioned above, it was my understanding that we would only want to change the allocated resources of the program and not change the maximum. So the integers in the text file are structured in the same way as a 2D array.
0 1 0
1 3 2
2 1 0
2 1 2
1 1 0
It is very important that the formatting of the integers in the text file are the same as above. The integers must also have a space between them as well, otherwise the they will be read in as a single integer.

Usage

To use this program you must first compile it. You can do this by simply using the Makefile that is provided. Run make main in the project directory and it will compile the program with gcc or clang (if you are on macOS). After the program is sucessfully compiled you can run ./main allocated.txt in the project folder. Be sure to add the allocated.txt file as the command line argument as that is where the program data is read from. To see different results you can edit the text file and replace the integers with different values. As said above, be sure to use the same format that is shown when changing the values in the text file. Afterwards you can run make clean in the project directory to remove the executable and dot files from the directory.

Conclusion

Overall, I found this project to be challenging and I still need to review the algorithm to get a better understanding of how exactly each detail works. But a program like this does help to visualize some of the aspects of the banker's algorithm.

bankers_algorithm's People

Contributors

david-j-tinley avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.