- Memory is central to the operation of a modern computer system.
- The part of the OS that manages the memory hierarchy is called the memory manager.
- to keep track of which parts of memory are in use and which parts are not in use,
- to allocate memory to processes when they need it and deallocate it when they are done,
- to manage swapping between main memory and disk when main memory is too small to hold all the processes.
- Memory consists of a large array of words or bytes, each with its own address.
- malloc library call
- used to allocate memory,
- finds sufficient contiguous memory,
- reserves that memory,
- returns the address of the first byte of the memory.
- free library call
- give address of the first byte of memory to free,
- memory becomes available for reallocation.
- Both malloc and free are implemented using the brk system call.
- The CPU fetches instructions from memory according to the value of the program counter. These instructions may cause additional loading from and storing to specific memory addresses.
- The memory unit sees only a stream of memory addresses; it does not know how they are generated (by the instruction counter, indexing, indirection, literal addresses, and so on) or what they are for (instructions or data).
- Accordingly, we can ignore how a program generates a memory address. We are interested only in the sequence of memory addresses generated by the running program.
- Memory management systems can be divided into two classes:
- Those that move processes back and forth between main memory and disk during execution (swapping and paging), (Memory Abstraction)
- Those that do not. Simpler. (No Memory Abstraction)