Giter Site home page Giter Site logo

vivekpatel111 / bankers-algorithm Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 1.44 MB

Banker’s Algorithm is a deadlock avoidance algorithm.

License: MIT License

C++ 100.00%
c-plus-plus borland-cpp university-project algorithms bankers-algorithm operating-systems

bankers-algorithm's Introduction

🏦 Banker's Algorithm 📚

Banker’s Algorithm, which is a deadlock avoidance algorithm. It is called the Banker’s Algorithm, because it could be used by a bank to make sure that money is allocated in such a way that all customer needs are met. When a new process enters the system, it declares the maximum number of instances that are needed. This number cannot exceed the total number of resources in the system. If the process can be accommodated based upon the needs of the system, then resources are allocated, otherwise the process must wait. The algorithm is actually made up of two separate algorithms: the safety algorithm and the resource allocation algorithm.

This program is tested using Borland C++ Compiler.

File Structure

File Name Description
BANKER.CPP main application
CLASS.CPP banker class declaration
DEFINE.CPP banker class definitions
GRAPHICS.CPP graphics related functions

Data Structures

The following data structures are needed:

no_of_process represents the number of processes and no_of_resource represents the number of resource types.

  1. Available

    1. A vector (array) of available resources of each type
    2. If available[j] = k, then k instances of Rj are available.
  2. Max

    1. A n no_of_process by no_of_resource matrix
    2. Defines maximum demand for each process
    3. maximum[i][j] = k, then process Pi may request at most k instances of resource Rj.
  3. Allocation

    1. A n no_of_process by no_of_resource matrix 2.Defines number of resources of each type currently allocated to each process
    2. allocation[i][j]=k, then process Pi is currently allocated k instances of Rj.
  4. Need

    1. A n no_of_process by no_of_resource matrix
    2. Indicates remaining resource need of each process
    3. If need[i][j] = k, then process Pi needs k more instances of Rj.
    4. need[i][j] = maximum[i][j] - allocation[i][j]

Screenshots

Application

Main Application Window

Main Application Window

Algorithm

Safe Sequence Check

Safe Sequence Check

Safe Sequence Result

Safe Sequence Result

Algorithm Inprogress

Algorithm Inprogress

Current State

Current State

Extra Flows

Input Validation

Input Validation

Memory Deallocation

Memory Deallocation

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.