Memory management system, C/C++ Programming

Assignment Help:

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 )


Related Discussions:- Memory management system

201 it, overloadstream insertion opertator to display the data of object on...

overloadstream insertion opertator to display the data of object on the console

HASHING, What is meant by open addressing? Explain various collision resolu...

What is meant by open addressing? Explain various collision resolution techniques with example

Define the multi dimensional arrays, Define the Multi Dimensional Arrays? ...

Define the Multi Dimensional Arrays? Consequently far we have considered arrays with only one dimension. It is as well possible to define an array which is having a 2-dimension

Implement binary heap in c++?, A:BinaryHeap.h ------------ #ifndef BI...

A:BinaryHeap.h ------------ #ifndef BINARY_HEAP_H_ #define BINARY_HEAP_H_ #include "dsexceptions.h" #include "vector.h" // BinaryHeap class // CONSTRUCTION: wi

Discuss polymorphism in c++, Problem 1. Discuss polymorphism in c++. ...

Problem 1. Discuss polymorphism in c++. Explaining Polymorphism 2. Write a program in c++ to read a 3X2 matrix and find smallest number in that matrix. Writin

Area Under Curve, Write a program to find the area under the curve y = f(x)...

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve between two points can b

Puzzles, #questioA Padovan string P(n) for a natural number n is defined as...

#questioA Padovan string P(n) for a natural number n is defined as: P(0) = ‘X’ P(1) = ‘Y’ P(2) = ‘Z’ P(n) = P(n-2) + P(n-3), n>2 where + denotes string concatenation. For a str

Expression, i need expression and its types with example programs in c++

i need expression and its types with example programs in c++

Programing solution, write a program that declares and initializes 2 intege...

write a program that declares and initializes 2 integer variable a and b with the value 35 and 14, and displays and calculates their sum,product,quotient and real division result.t

Derivatives and symbolic math, #Hi, I''m planning to derive the escape velo...

#Hi, I''m planning to derive the escape velocity through C++. I would just like to know if it''s possible to differentiate symbolic functions? Do I need to download libraries,etc?

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd