What is Memory?
- Memory is a device that is used to store data or programs (sequences of instructions) on a temporary or permanent basis for use in an electronic digital computer.
- It consists of one or more RAM chips that have several memory modules.
What is Memory Management?
- Memory Management is the act of managing computer memory.
- A collection of techniques for providing sufficient memory to one or more processes in a system.
- Especially when the system does not have enough memory to satisfy all processes requirements simultaneously.
Techniques include:
- Virtual memory
- Paging
- Swapping
Why Memory Management?
- Devices don’t have much memory and if we are memory hogs, it means we are heading for trouble.
- If memory is not managed properly it leads to embarrassing crashes.
Virtual Memory
- An imaginary memory area is supported by some operating systems.
- Each process sees its own address space.
- MMU (Memory Management Unit) translates between virtual addresses and physical addresses.
Paging
- A technique used by virtual memory operating systems to help ensure that the needed data is available as quickly as possible
Swapping
- System swaps pages of memory to and from secondary storage (the disk).
Requirements of Memory Management
- Memory Management Systems on multi-tasking operating systems usually deal with the following issues:
- Relocation
- Protection
- Sharing
- Logical organization
- Physical organization
Relocation
- In systems with virtual memory, programs in memory must be able to reside in different parts of the memory at different times.
- This is because there is often not enough free space in one location to fit the entire program.
- The virtual memory management unit must also deal with concurrency.
- Memory management in the operating system should therefore be able to relocate programs in memory and handle memory references and addresses in the code of the program so that they always point to the right location in memory.
Protection
- Processes should not be able to reference the memory of another process without permission is called memory protection.
- Memory Protection prevents malfunctioning code in one program from interfering with the operation of other running programs.
Sharing
- Shared memory is one of the fastest techniques for inter-process communication.
- The memory allocated for specific processes is normally isolated; processes sometimes need to be able to share information.
- Even though parts of memory for different processes are normally protected from each other, different processes sometimes need to be able to share information and therefore access the same part of memory.
Logical Organization
- Programs are often organized in modules.
- Some of these modules could be shared between different programs; some are read-only and some contain data that can be modified.
- Memory management is responsible for handling this logical organization that is different from the physical linear address space.
- One way to arrange this organization is through segmentation.
Physical Organization
- Memory is usually divided into fast primary storage and slow secondary storage.
- Memory management in the operating system handles moving information between these two levels of memory.