Assignment3 - CSci 4061: Introduction to Operating Systems...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
CSci 4061: Introduction to Operating Systems Assignment 3: Dynamic Memory Management Due: March 29 th 10pm, you may work in a group of 2 or 3. Purpose: In this assignment, you will become more familiar with the issues that surround dynamic memory management: dynamic memory allocation and deallocation. Understanding these issues is important in designing memory-efficient run-time systems, an important task of the systems programming. You will make use of Unix library/system calls for memory management: {re} malloc , free , memcpy . You will also measure the performance of your dynamic memory manager and show (hopefully) how we can outperform the Unix heap management routines! In addition, you will also learn about interrupt-driven programming (via alarm signals) and separately compiled functions. Description: 1. Dynamic Memory Management Functions Dynamic memory allocation and deallocation in Unix is achieved via the malloc family of system calls along with free . However, for programs that wish to perform a great deal of allocation and deallocation, this introduces a lot of overhead due to the expense of making library/system calls. In addition, in some environments malloc may not be thread-safe or signal-handler-safe , meaning that dynamic memory allocation may not work correctly if called by threads or within signal handlers because of race conditions in the heap management routines. To combat these problems, you decide to write your own dynamic memory manager and make it available to applications that wish to utilize dynamic memory in a more convenient and efficient manner. Your memory manager will “manage” a pool of dynamic memory divided into a fixed number of fixed- size chunks . For example, the pool of dynamic memory might be 100 chunks of 64 bytes (a total of 6400 bytes). Since most applications will want memory chunks of some size corresponding to a data structure type, this is a reasonable restriction. Here is the interface of your memory manager. You must implement the following functions of the memory manager: int mm_init (mm_t *MM, int how_many_chunks, int chunk_size); // allocate all memory, returns -1 on failure void *mm_get (mm_t *MM); // get a chunk of memory (pointer to void), NULL on failure void mm_put (mm_t *MM, void *chunk); // give back ‘chunk’ to the memory manager, don’t free it though! void mm_release (mm_t *MM);
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 4

Assignment3 - CSci 4061: Introduction to Operating Systems...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online