Skip to content

mario-nakazawa/coding.freelist

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The Free list Assignment

This assignment is designed to help students understand how a linked list structure can be embedded within the simulated memory while building a free list for allocated memory.

This process follows what is described starting on page 7 of OSTEP: Free List Management

The program with stubs for functions has already been created for you:

  • freeList.h - the header of the free list class. DO NOT CHANGE THIS FILE
  • freeList.cc - the implementation file for the free list class. You will be implementing functions here.
  • main.cc - the file containing the main() function only. You will be making some changes to this file as you test your program. In its current form, coalesce_forward() will not do anything. You will need to change the way that memory blocks are reserved and freed to enable the simple coalescing function to work.

You are to implement the following in order:

  • the constructor
  • reserver_space() - the description for what needs to happen is defined in the header file. Note that after any number of these calls, there is still only item in the free list (the block of free space at the end.
  • free_space() - the description for what needs to happen is defined in the header file. Note that it does not check for valid addresses and assumes that the process saved the correct one. As this function is repeatedly called (for each previously allocated chunks of memory), the free list increases and should be shown then it is printed.
  • coalesce_forward() - the description for what needs to happen is defined in the header file. THIS FUNCTION IS HARD and only works to find blocks of free memory that are consecutive elements in the free list. Do not implement anything more sophisticated.

Notes:

  • the main() function is currently built so that it creates an embedded free list in the heap (simulated as a dynamically allocated array of long ints), reserves a bunch of blocks and frees them, calling the print function after each action. do not change the order of these operations! All reserves should be done BEFORE any frees because we want to have the head variable to refer to the last block of memory.
  • Once a free_space() function is called, the head variable will be pointing to the location of the most recently freed chunk, so calling reserve_space() will break.
  • We will be doing some pointer arithmetic.
  • In order to create the program, you need to type make in the directory where the source files and Makefile are located.
  • You will be getting some practice using the Linux command line; it is a very good skill to develope!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published