Pre-lab 10x

Goals

  • Learn to design and to implement a custom memory allocator: The operating system provides mechanisms for dynamic allocation in contiguous memory spaces. There are multiple criteria to assess how well these mechanisms work, including speed of execution and the minimization of external fragmentation (to that end, you learned of different policies for allocation decisions, such as first- fit, best-fit, and worst-fit). In this lab, you will design and implement a memory allocation system to work in user space and apply the concepts you have studied so far.

Credits

This lab was developed by Prof. L. Felipe Perrone. Permission to reuse this material in parts or in its entirety is granted provided that this credits note is not removed. Additional students files associated with this lab, as well as any existing solutions can be provided upon request by e-mail to perrone[at]bucknell[dot]edu


Set Up

Create a new directory for today’s work:

~/youruserid/csci315/Labs/Lab10

Copy to this directory all the files developed for your custom memory allocator. Using the terminal, you would do this with commands:

  • cd ~/youruserid/csci315/Labs/Lab10
  • cp -R ../Labs/Lab9 . 

Create a file called answers.txt where you will write BRIEF and CLEAR answers to the questions (P-1), (P-2), (P-3).

Problem (30 points)

P-1 What type(s) of fragmentation is (are) possible with a custom memory allocator like yours? Internal, external or yet something different?

P-2 Propose two or more performance metrics (unrelated to fragmentation) that you could use to assess how well your memory allocator works.

P-3 You will create a new function in your allocator to compute the average fragmentation created in memory after repeated, randomly interleaved calls to your allocate and deallocate functions. Before you get down to coding this function, though, think about how you will implement it and write here your algorithm in the form of an algorithm in pseudo-C code. The signature for this function should be something like:

double average_frag();

If you change this API, make sure to document your new signature in the answer to question 3.

Finally, once you have the algorithm for average_frag, implement this function in your allocator. That is, you will be changing your allocator.h and allocator.c to include the new function (make sure to use Doxygen comments in your header file to explain what your function does and how its API works).

When you are done with this, you need to:

  • git add answers.txt
  • git add include/allocator.h
  • git add src/allocator.c
  • git commit “pre-lab 10 completed”
  • git push
Print Friendly