OS memory services


Operatingsystems offer some kind of mechanism for (both system and user) software toaccess memory.

   
Inthe most simple approach, the entire memory of the computer is turned over toprograms. This approach is most common in single tasking systems (only oneprogram running at a time). Even in this approach, there often will be certainportions of memory designated for certain purposes (such as low memoryvariables, areas for operating system routines, memory mapped hardware, video RAM,etc.).
    
Withhardware support for virtual memory, operating systems can give programs theillusion of having the entire memory to themselves (or even give the illusionthere is more memory than there actually is, using disk space to provide theextra “memory”), when in reality the operating system is continually movingprograms around in memory and dynamically assigning physical memory as needed.Even with this approach, it is possible that some virtual memory locations aremapped to their actual physical addresses (such as for access to low memoryvariables, video RAM, or similar areas).
    
Thetask of dividing up the available memory space in both of these approaches isleft to the programmer and the compiler. Many modern languages (including Cand C++) have service routines forallocating and deallocating blocks of memory.
    
Someoperating systems go beyond basic flat mapping of memory and provide operatingsystem routines for allocating and deallocating memory. The Macintosh, for example, has two heaps (a system heap and anapplication heap) and an entire set of operating system routines forallocating, deallocating, and managing blocks of memory. The NeXTgoes even further and creates an object oriented set of services for memorymanagement.
    
Withhardware support for segments or demand paging, some operating systems (such asMVS and OS/2)provide operating system routines for programs to manage segments or pages ofmemory.