Memory management system, C/C++ Programming

1. Basic Heap: Each memory location in our model of the RAM will be an instance of type Memory:

2. typedef union Memory_u Memory;

3. union Memory_u{

4. char character;

5. unsigned int size;

6. unsigned long address;

7. };

In each memory location of our simulated heap, which we'll call a memory cell, we can either store actual data (the character field) or other information that is needed for the dynamic memory management.
Each time we allocate some memory on our simulated heap, we need to use at least four (4) consecutive memory cells: 

The first memory cell uses the size field to say how many data memory cells are allocated (we'll call this the head memory cell for our block of allocated memory);

The next memory cell uses the address field to indicate where the head memory cell is for the block of allocated memory that occurs before this current block in the simulated heap. If there are no blocks allocated that are located before this block, the address field will be zero (start of the heap and forbidden memory location);

the next one or more memory cells (defined by the head memory cell) are the actual allocated memory cells for the data (the characters);

the last memory uses the address field to indicate where the next free memory location in the simulated heap is. Since each memory allocation needs at least four consecutive memory cells, the next free memory location must have at least four consecutive free memory cells.

Our simulated heap will simply be an array of Memory in the actual heap. Array index zero (0) will correspond to memory address zero in our simulated heap and is off limits (to read or write) just as memory location zero (NULL) is off limits in your normal programs.

You will implement all of the functions found in nonstdlib.h (found here) that are not already defined in nonstdlib.c (found here). These functions include Memory* initializeHeap(unsigned long size);

// Purpose: allocate memory on the actual heap for our

// simulated heap. Returns a pointer to the first

// memory location that we have reserved for our

// simulated heap

// (This function is partially defined for you )

// (you can add code to it, but do not change )

// (the last line of it in the .c file )

Posted Date: 4/1/2013 2:44:17 AM | Location : United States







Related Discussions:- Memory management system, Assignment Help, Ask Question on Memory management system, Get Answer, Expert's Help, Memory management system Discussions

Write discussion on Memory management system
Your posts are moderated
Related Questions
Assume that a Binary Search Tree is constructed by repeatedly inserting exact values in to the tree. Argue that the number of nodes examined in searching for a value in the tree is

There is a pebble merchant. He sells the pebbles, that are used for shining the floor. His main duty is to take the length of the room’s sides. But he sometimes mistakes doing that

With this assignment you will build a toy program that manipulates pointers to integers. You will develop the same main program fragment in both C and Assembler. Thus, you'll get t

Project Description:  LOOKING TO DEVELOP A ONLINE POKER Web Application. WEBSITE WILL BE DEVELOPED OVER THE NEXT 6 MONTHS Duration & WILL REQUIRE FULL SOFTWARE CODING OF WEB

how is a beti a beti

Objective:  Construct a C program that controls the LCD display, and is capable of displaying strings.  Add functions to the C program that allows more control over the display.

C program to print L diagonal triangle: void main() {                 int i=0,j=0;                 int arr[rows][cols];                 for (i=0; i

how can i write reverse digit function like writing 1234 and printing 4321

Implementing files in c++

Develop Custom Mql4 Code/Fxdreema block Project Description: I need the subsequent code written in mql4 and integrated as custom block(s) in fxdreema: for each trade: C