GithubHelp home page GithubHelp logo

tusharnankani / operatingsystemalgorithms Goto Github PK

View Code? Open in Web Editor NEW
25.0 1.0 8.0 475 KB

Algorithms built with Java for a better understanding of Operating System ✨

License: GNU General Public License v3.0

Java 92.32% Python 2.39% C++ 5.29%
memory-management memory-allocation memory-allocation-simulation operating-system os java free-partitions scheduling-algorithms paging-simulation page-replacement-algorithm

operatingsystemalgorithms's Introduction

OperatingSystemAlgorithms

OperatingSystemAlgorithms

Table of contents

Introduction

  • Memory Allocation Simulator built with JAVA, for a better understanding of how memory allocation works in an Operating System. It simulates common memory allocation strategies:
    • First-Fit
    • Best-Fit
    • Worst-Fit

This repository also contains the code for

  • Scheduling Algorithms
  • Page Replacement Algorithms
  • Paging Simulator
  • Disk Scheduling Policies

Demonstration

  • Welcome to the Memory Allocation Simulator.
  • First, we ask whether the user wants to enter a values or not, if not, then a few values are already hardcoded.
  • The hardcoded values are important for understanding, debugging and saving time.

  • After taking the input value of the Memory Divisions, their current status (Free/Not Free) and the process numbers, we print the current table of the Memory Allocation.

  • So now, we take the size of the input process, and a menu comes up.

  • Output for the First Fit

  • Output for the Best Fit

  • Output for the Worst Fit

Algorithms

A simple Memory Allocation Simulatory built with JAVA, for a better understanding of how memory allocation works in an Operating System. It simulates common memory allocation strategies:

  • First-Fit
    • In the first fit approach is to allocate the first free partition or hole large enough which can accommodate the process.
    • Advantage: It finishes after finding the first suitable free partition. Fastest algorithm because it searches as little as possible.
    • Disadvantage: Internal Fragmentation - The remaining unused memory areas left after allocation become waste if it is too smaller. Thus, request for larger memory requirement cannot be accomplished.
  • Best-Fit
    • The best fit deals with allocating the smallest free partition which meets the requirement of the requesting process. This algorithm first searches the entire list of free partitions and considers the smallest hole that is adequate.
    • Advantage: It then tries to find a hole which is close to actual process size needed. Memory utilization is much better than first fit as it searches the smallest free partition first available.
    • Disadvantage: It is slower and may even tend to fill up memory with tiny useless holes.
  • Worst-Fit
    • In worst fit approach is to locate largest available free portion so that the portion left will be big enough to be useful. It is the reverse of best fit.
    • Advantage: Reduces the rate of production of small gaps.
    • Disadvantage: If a process requiring larger memory arrives at a later stage then it cannot be accommodated as the largest hole is already split and occupied.

Before processing every simulation, the user has to input the Current Memory Division/Allocation, i.e. Memory Division, Status, Process Name.

Currently, the memory allocation is hardcoded for saving time and easy debugging of this example.

Current Memory Allocation

If input process is of size 200 KB, then:

Memory Allocation - First Fit

Memory Allocation - Best Fit

Memory Allocation - Worst Fit

Local Setup

  • Download the latest version of Java - Java SE - Downloads | Oracle.
  • Clone the repository: git clone https://github.com/tusharnankani/MemoryAllocationSimulator.git
  • Open this directory in Command Promt or Shell.
  • Compile the file using the command: javac MemoryAllocation.java
  • Run the file using the command: java MemoryAllocation

Author

Tushar Nankani

LinkedIn | Twitter

License 📜

GPU License

operatingsystemalgorithms's People

Contributors

imgbotapp avatar tusharnankani avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

operatingsystemalgorithms's Issues

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.