1.4 Memory Management Flashcards
Dynamic Memory Allocation
OS allows provides mechanism for programms to Dynamically allocate memory via system libraries and special functions
Memory Fragmentation
Inefficient splitting of memory space into small chunks in the main memory or on a hard disk.
Allocation Strategy
This is an algorithm that decides which free resource (here, memory region) is allocated to which request.
First Fit
- Allocate first free matching Block
- Simple and fast
But - Small free chunks accumulate at small adresses
Next fit
Same as first, but continue search at last allocation
Best fit
- Allocate the block that leaves the smallest reminder
But - Allocation of many small residual gaps
Worst fit
- Allocate the block that leaves the largest reminder
- Remaining gaps remain large and therefore easy to allocate
What is memory protection and why is it important?
Ensures that multiple processes are only accessing designated address space.
Process isolation
* Malfuntioning programs can only impact own address space
Data security
* Prevents unauthorized access to sensitive data
How is memory protection archieved?
Hardware support of the CPU
* Detects attempts
* Raises exception
* Triggers OS to stop process
Boundary registers
- Part of the CPU Check validity of memory address accessed by process
- Uses start and end information of process control block
Recap: What happens if process violates memory boundaries?
- Memory Access violation detected by Boundary registers via process control block
- Boundary registers promption CPU to hand over CPU to hand over control to OS
- Corrective action
Which part of the computer uses logical and which part physical addresses to acces memory?
- Address bus, physical
- CPU and programs, logical
Which part is doing the conversion of logical to physical addresses?
MMU
MMU
- MMU is part of the CPU
- Conversion of virtual to physical addresses
- Consists of two registers: Base register and Limit register
Base Register
- Stores starting physical address of programm memory space
- When programs logical address is generated, it assumes 0
- MMU adds value in base register to logical address to determine physical address
Limit register
- Contains size of programms address space
- Checks allowed memory range
- Memory protection
Benefits of Logical addresses
- Allow programms to be written and stored as if running and stored as dedicated block, starting from 0
- simplifies programming
- flexible memory management
- Secure Multitasking
What is the Disadvantage of Virtual Memory Addresses and how can it be mitigated?
- Contingious memory space is required
- This can only be achieved if there is enough space in immediate physical range
Mitigation:
Virtual memory Addresses by way of paging
Paging
With this method of memory management, the main memory is divided into pages (in the form of tables) and managed by the operating system in cooperation with the MMU.
Memory Page
- Blocks of a fixed length in the virtual address space used by processes, managed through virtual memory management techniques like paging.
Page Frames
Physical memory block in Main meory
Page Tables
In virtual memory management with paging, address translation is performed via page tables, which store, for each process, which of its memory pages are located on which page frame within the main memory.
- Every Process has its own Page Table
TLB
Translation Lookaside Buffer
* Temporary storage of recent table entries
* Faster Address Translation
What are the three steps for converting virtual addresses to physical ones?
- Identify Memory Page
- Locate Page frame via MMU and page tables for Mapping
- Calculate Physical Addresses