Memory and Memory Management

October 29, 2016
Categorised in: Operating System Design
Memory is a large array of words or bytes.
CPU can only access content from main memory and registers (built into processor)
Data / instruction can not be read from secondary storage by processor . It needs to be moved from secondary storage to main memory.
Memory Management Tasks
- managing Primary Memory
- moving processes back and forth between main memory and disk during execution
- keeping track of allocated and free memory
- decides which process will get memory at what time
Is the task carried out by the OS and hardware to accommodate multiple processes in main memory
If only a few processes can be kept in main memory, then much of the time all processes will be waiting for I/O and the CPU will be idle
Hence, memory needs to be allocated efficiently in order to pack as many processes into memory as possible
Three design constraints of memory subsystem
- Size
- Speed
- Cost
Memory Hierarchy
Upward: Cost, speed increases
Downward: Size increases
Memory Management Requirements
- Relocation
- Protection
- Sharing
- Logical organization
- Physical organization
Relocation
programmer cannot know where the program will be placed in memory when it is executed
a process may be (often) relocated in main memory due to swapping
swapping enables the OS to have a larger pool of ready-to-execute processes
memory references in code (for both instructions and data) must be translated to actual physical memory address
Protection
processes should not be able to reference memory locations in another process without permission
impossible to check addresses at compile time in programs since the program could be relocated
address references must be checked at run time by hardware
Sharing
must allow several processes to access a common portion of main memory without compromising protection
cooperating processes may need to share access to the same data structure
better to allow each process to access the same copy of the program rather than have their own separate copy
Logical Organization
users write programs in modules with different characteristics
- instruction modules are execute-only
- data modules are either read-only or read/write
- some modules are private others are public
To effectively deal with user programs, the OS and hardware should support a basic form of module to provide the required protection and sharing
Physical Organization
secondary memory is the long term store for programs and data while main memory holds program and data currently in use
moving information between these two levels of memory is a major concern of memory management (OS)
it is highly inefficient to leave this responsibility to the application programmer
Pratik Kataria is currently learning Springboot and Hibernate.
Technologies known and worked on: C/C++, Java, Python, JavaScript, HTML, CSS, WordPress, Angular, Ionic, MongoDB, SQL and Android.
Softwares known and worked on: Adobe Photoshop, Adobe Illustrator and Adobe After Effects.