memorymanagement - Chapter 5 Memory Management Primary...

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

View Full Document Right Arrow Icon

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

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

Unformatted text preview: Chapter 5 Memory Management Primary memory is a prime resource in computer systems. Its management is an important function of operating systems. However, in this area the operating system depends heavily on hardware support, and the policies and data structures that are used are dictated by the support that is available. Actually, three players are involved in handling memory. The first is the compiler, which structures the address space of an application. The second is the operating system, which maps the compiler’s structures onto the hardware. The third is the hardware itself, which performs the actual accesses to memory locations. 5.1 Mapping Memory Addresses Let us first review what the memory is used for: it contains the context of processes. This is typically divided into several segments or regions. Different parts of the address space have different uses The address space is typically composed of regions with the following functionalities: Text segment — this is the code, or machine instructions, of the application being executed, as created by the compiler. It is commonly flagged as read-only, so that programs cannot modify their code during execution. This allows such memory to be shared among a number of processes that all execute the same program (e.g. multiple instances of a text editor). Data segment — This usually contains predefined data structures, possibly initial- ized before the program starts execution. Again, this is created by the compiler. Heap — this is an area in memory used as a pool for dynamic memory allocation. This is useful in applications that create data structures dynamically, as is common in object-oriented programming. In C, such memory is acquired using the malloc 99 library routine. The implementation of malloc , in turn, makes requests to the operating system in order to enlarge the heap as needed. In Unix, this is done with the brk system call. Stack — this is the area in memory used to store the execution frames of functions called by the program. Such frames contain stored register values and space for local variables. Storing and loading registers is done by the hardware as part of the instructions to call a function and return from it. Again, this region is enlarged at runtime as needed. In some systems, there may be more than one instance of each of these regions. For example, when a process includes multiple threads, each will have a separate stack. In addition, the data and heap may each be composed of several independent seg- ments that are acquired at different times along the execution of the application. In some systems it is also possible to share individual segments of memory in different ways among a number of processes....
View Full Document

This note was uploaded on 02/14/2012 for the course CSCE 313 taught by Professor Gu during the Spring '11 term at Texas A&M.

Page1 / 25

memorymanagement - Chapter 5 Memory Management Primary...

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

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