Lecture 9 - Memory Management Flashcards
Main memory and registers are only storage ___ can
access directly
CPU
Memory unit only sees a stream of:
- ___ or
- ___
- addresses + read requests, or
2. address + data and write requests
Register access is done in ___ CPU clock (or less)
one
Main memory can take ___ cycles, causing a ___
many
stall
___ sits between main memory and CPU registers
cache
How do we provide protection? Why?
Who makes sure the base and limit is respected?
How do we protect the base and limit registers?
We can provide this protection by using a pair of base and limit registers define the logical address space of a process
base + limit
<»
base
The CPU must check every memory access generated in usermode to be sure it is between base and limit for that user
The instructions to loading the base and limit registers are
privileged
Programs on disk, ready to be brought into memory to execute form an
___
input queue
Addresses represented in different ways at different stages of a program’s life
1. Source code addresses usually ___
2. Compiled code addresses bind to ___
i.e. “14 bytes from beginning of this module”
3. ___ will bind relocatable addresses to ___
addresses
i.e. 74014
4. Each ___maps one address space to another
- symbolic
- relocatable addresses
- Linker or loader, absolute
- Binding
Address binding of instructions and data to memory addresses
can happen at three different stages. What are they?
- Compile time: If memory location known a priori, absolute code can be generated; must recompile code if starting location changes
- Load time: Must generate relocatable code if memory location is not known at compile time
- Execution time: Binding delayed until run time if the process can be moved during its execution from one memory segment to another
-> Need hardware support for address maps (e.g., base and
limit registers)
Draw the diagram of multistep processing of a user program.
See slide 7
The concept of a logical address space that is bound to a separate ___ is central to proper memory management
Physical address space
What’s the similarities and difference between logical address and physical address?
- Logical address – generated by the CPU; also referred to as virtual address
- Physical address – address seen by the memory unit
Logical and physical addresses are the same in compile-time and load-time address-binding schemes; logical (virtual) and physical addresses differ in execution-time address-binding scheme
Define:
- Logical address space
2. Physical address space
Logical address space is the set of all logical addresses generated by a program
Physical address space is the set of all physical addresses generated by a program
What is the role of the Memory-Management Unit (MMU)
Hardware device that at run time maps virtual to physical address
Explain how the relocation register MMU works
The value in the relocation register is added to every address generated by a user process at the time it is sent to memory
logical = 346 relocation register (14000) = 14346
- Explain dynamic loading.
- What’s the advantage?
- Where are routines kept?
- When is it useful?
- Where is it implemented?
- The entire program does need to be in memory to excute
Routine is not loaded until it is called - Better memory-space utilization; unused routine is never loaded
- All routines kept on disk in relocatable load format
- Useful when large amounts of code are needed to handle infrequently occurring cases
- No special support from the operating system is required
Implemented through program design
OS can help by providing libraries to implement dynamic loading
What’s the difference between static and dynamic linking?
Static linking – system libraries and program code combined by the loader into the binary program image
Dynamic linking –linking postponed until execution time
- Explain how dynamic linking works.
2. What is it particularly useful for?
- Small piece of code, stub, used to locate the appropriate memory-resident library routine
Stub replaces itself with the address of the routine, and executes the routine
Operating system checks if routine is in processes’ memory address
If not in address space, add to address space - Dynamic linking is particularly useful for libraries
System also known as shared libraries
- What problem does Contiguous allocation solve?
2. What are the two partitions in Contiguous allocation?
- Main memory must support both OS and user processes
Limited resource, must allocate efficiently
Contiguous allocation is one early method - Main memory usually into two partitions:
Resident operating system, usually held in low memory with interrupt vector
User processes then held in high memory
Each process contained in single contiguous section of memory
In contiguous allocation,
- ___ are used to protect user processes from each other, and from changing operating-system code and data
- Base register contains value of smallest ___
- Limit register contains range of ___, where each ___ must be less than the limit register
Can then allow actions such as kernel code being ___ and kernel changing size
- Relocation registers
- Physical address
- Logical address
- Transient