Giter Site home page Giter Site logo

cs3113sp21-project2's Introduction

Intro to OS - Project 2 (Memory Management)

by Parker Brandt (ID: 113521131)

How To Run

In order to run this program, a Makefile is provided with two commands: all and clean
To compile and run the program, type and enter "make all" in the command line
This will create an executable file named "project2"
To run the executable type in the command line "./project2 [MEMORY ALGORITHM] [NUMBER OF BYTES TO ALLOCATE] [Script Filename]"

Functions

char** split(char* string, char split)
The split function takes in a string (char* string) and splits it along a split character (char split). The function then returns an array of strings.
For example, if the input string is "This is a test", and the string is split along spaces, then the function will return ["This", "is", "a", "test"].

void insertInArray(Process addProc, Process* array, int index, int length)
This function inserts a new Process into an array of processes.
NOTE: A Process is a struct in the program that houses data about a Process' name, size, and start and end indices.
The parameter addProc is the process to be inserted into the parameter array. The parameter index is provided to tell the function where to insert the process into in the array. Lastly, the parameter length is the current length of the array before the insertion.

void removeFromArray(Process* array, int index, int length)
This function removes an element from the parameter array provided at the parameter index. The other parameter length is provided to help with looping.

Memory Algorithm Functions

int firstFit(Process newProc, Process* procList, int length, unsigned long totalMemory)
The First Fit algorithm is a memory allocation algorithm that finds the first hole in memory that is big enough to hold a process and stores it there.
The function performs the first fit algorithm and adds the parameter newProc to the procList array that stores the processes. The parameter length is the current length of the array of processes and totalMemory is the total amount of memory that the processes can be stored in.
The function returns the index where the process was inserted, or on failure, it will return -1.

int bestFit(Process newProc, Process* procList, int length, unsigned long totalMemory)
The Best Fit algorithm is a memory allocation algorithm such that when allocating memory for a process, the algorithm iterates through the entire memory array to find the smallest hole that is still big enough for the process, and allocates the process to that spot.
The parameters for bestFit() are the same as for firstFit(), and the return value is the same where the function returns the index to where the process was inserted, or -1 on failure

int worstFit(Process newProc, Process* procList, int length, unsigned long totalMemory)
The Worst Fit algorithm is a memory allocation algorithm that is similar to the Best Fit algorithm, but instead of finding the smallest hole that is big enough for the process, the Worst Fit algorithm finds the largest hole and allocates the process there.
The parameters and return values are the same for Worst Fit as they are for First Fit and Best Fit.

int nextFit(Process newProc, Process* procList, int* nextPtr, int length, unsigned long totalMemory)
The Next Fit algorithm is a memory allocation algorithm that is similar to the First Fit algorithm, but Next Fit keeps a pointer to the next location that can allocate a process.
Most of the parameters are the same for the Next Fit algorithm as the rest of the algorithms, except Next Fit has the next pointer as a parameter as nextPtr. The return values for the Next Fit function are the same as the previous memory allocation functions.

cs3113sp21-project2's People

Contributors

parkerbrandt avatar

Watchers

 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.