Answers/Solutions to Exercises in Chapter 5, Exercise 5

E5: What are the differences between the system stack and the system heap? Try to list all differences --- in their roles and purpose as well as in their implementations.

A5:  The purpose of system stack is to control the flow (the execution) and to provide the communication between the program and the functions being called (arguments and return values). The stack is organized as a stack data structure, for it best corresponds to the flow of control. The system heap is the data structure used to control segments of dynamic memory intended for dynamic allocation. It has the form of heap to facilitate a fast and efficient finding of a suitable segment to allocate and a fast and efficient way to put a deallocated segment back in the "pool". The system stack and the system heap occupy different part of memory.

Back to Answers/Solutions Index                          Back to Answers/Solutions for Chapter 5 Index