Coder Social home page Coder Social logo

memory-management's Introduction

Memory-Management

In this assignment, we are simulating memory management as is done in interpreted languages like Python or Java.

When a program requests requests a block of memory dynamically, the system must allocate memory, and when a program terminates or frees memory previously requested, the system must deallocate memory.

For the sake of this assignment, we will assume we have only 64 MB of memory. Starting at zero memory allocation, we will process several kinds of transactions:
--- Allocate a block of memory dynamically
--- Deallocate a block obtained earlier

From time to time, we will print out the contents of the data structures involved.

Write a program in any language to accomplish this. Your program (which may be in several files) should do the following:

--- Define an array to represent one block of memory from which you can allocate or deallocate.

--- Once allocated, the return value should include the starting address (an integer).

--- Assignments like a=b, will increase the reference count of the memory previously allocated to a

--- Deallocation only happens when the reference count goes to 0.

--- Create two linked lists of blocks. One list contains blocks that are presently in use, and the other contains blocks that are not presently in use. This will help in allocation of memory.

--- Periodically carry out memory compaction. This will update the pointers as well as the two linked lists.

--- Open and read the input file and carry out the transactions. You can define specific formats for allocation and deallocation.

--- After all transactions, reprint the contents of both lists. If possible, print contents in another output file.

--- Be sure you close the files before the program exit.

--- If there is no sufficiently large block for allocation, then first try to compact the memory and if still not possible then print an error message

Please submit code as well as Documentation of your code along with sample input and output. Your documentation should clearly mention about any assumptions, have some diagrams on how allocations and deallocations are happening.

Also, you will have to use style guidelines given here: https://faculty.cs.niu.edu/~byrnes/csci240/240doc.htm

Example [You can define your own transactions]:

a = allocate (500); // Will allocate 500 bytes, and a will be assigned starting address of 500 bytes // The linked lists will be updated

b = a; // reference count of the allocation will increase by 1, value of b will be value of a

free (a); // reference count will decrease by 1

free (b); // Deallocate 500 bytes from given starting address value given by b // Both the linked lists will be updated Deadline: 21 Jan 2023

memory-management's People

Contributors

shoaib0657 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.