Memory: Basics and Segmentation Flashcards
In the early days a process took the whole memory. With multiprogramming and time sharing this was changed.
- What sort of problems occurred?
- How could those problems be fixed?
- What new problem occured through the fix?
- Processes took in the beginning the full memory space. We have to store the processes somewhere outside of memory. To change processes is highly inefficient.
- Solution: Multiple processes in memory at the same time
- New problem: Protection is required.
Keypoints of virtual address spaces :
- What does it contain?
- virtual addresses
- Protection
- Full memory state (code, data, stack, heap)
- Virtual addresses which do not correspond to physical address (virtual address space can be larger than physical)
- Protection through isolation
Target goals of virtual address spaces?
- Efficiency: Memory has to be highly efficient
- Transparency: Illusion that a process has access to the full memory space (We don’t want to work with memory problems while coding in C)
- Protection: A process should only have access to his memory.
- What is the virtual address space exactly?
- Where is it stored?
- The virtual address space is for every process. It represents the memory space to give the process the meaning that it has all memory zur Verfügung.
- It is stored in memory (or HDD -> swapping). Memory is split between processes.
- What is a virtual address?
- What is a physical address?
- What are the differences?
- A virtual address to process data in memory. This has to be translated to a physical to be accessed.
- Physical address can be accessed on the fly.
- The process has most of the time not access to the physical address to reduce complexity for the programmer.
Address Translation:
- What is it?
- What are the roles of the OS and the hardware?
- This is the tranlsation from virtual address to physical address
- OS: Manages memory, knows which part belongs to which process
- Hardware: Memory Management Unit (MMU) translates efficiently.
What is “base and bounds”?
- First approach to address translation
- Uses 2 HW registers: Base and Bound (Limit)
- Programs are compiled to start at address 0
- Base starts at physical address and bounds = base + size of address space
- Physical address = base + virtual address
- If physical address > bounds -> Fault
- What is external fragmentation?
- How does it happen?
- What is the problem?
- If there is memory space available but distributed in small chunks all over the place.
- By user memory allocation.
- If we got 24 Kb free memory, which is all over the place, we cannot give a process 20Kb memory.
What is the problem with compaction as solution for external fragmentation?
Compaction compacts the memory after each memory switch (free to free and used to used.
- This costs a lot of time
- impossible (No control over user assigned memory)
What is a possible solution to external fragmentation?
Splitting and Coalescing.
- Free frame linked list is used to keep track on memory
- By memory request, some free memory is split.
- When memory is returned, it can be coalesced into a bigger chunk of memory (if it is at the same address)
What are the problems of dynamic relocation (e.g. base and bounds)?
- Internal fragmentation
- Hard to manage virtual address space that is bigger than physical
- What is segmentation?
- What problem does it solve?
- Segmentation divided the virtual address space into segments. Each segments has its own base and bounds registers/variables whatever.
- It solves the problem of dynamic relocation: Internal fragmentation
How does the addressing work with segmentation? How does the hardware know which segment belongs to which virtual address?
Use the first 2 bits to number the segments (or more if there are more than 4 segments). This splits the address into segment number and offset.
Segmentation:
- What is a problem with the stack segment and how is it solved?
- How can we share segments?
- The stack grows negative. Therefore we need to know in which direction a segment grows.
- We need an additional protection bit to show if we can savely read from it (because it is never written to) or not.