13. Virtual Addresses Flashcards
Where does the stack start and which direction does it grow?
The stack starts at the top of the address space and grows down
Where does the heap start and which direction does it grow?
The heap starts towards the bottom of the address space and grows up
Will the stack and the heap ever meet (grow into each other)?
Probably not. That would require the stack, heap, or both to be huge.
What 3 things are required to implement the address space abstraction?
- Address translation, meaning 0x100 for Process 1 is not the same location as 0x100 for Process 2
- Protection (privacy), meaning processes can only access their own address space
- Memory management, meaning the ability to have a greater sum of address spaces than the amount of physical memory on the machine
How does the address space contain a level of indirection?
The address space abstraction brings with it the breaking of the direct connection between a memory address (as perceived by the process) and a physical memory location
This means that there is no guarantee that 0x100 for the process is 0x100 on the physical memory
Forcing a process to translate a reference (mem address) is an example of a level of indirection. What features does this level of indirection provide the kernel with?
A process address has to be translated into a corresponding physical memory address. This level of indirection allows the kernel greater control over the physical memory.
References to physical memory addresses can be revoked (removed from page table?), shared (added to page table), moved, and altered (mapped to another location)
What are the two components of the memory interface?
Load and store.
Load(address) loads data from the given address, usually into a register or another memory location
Store(address, value) stores value to the given address.
What does a physical address point to?
Physical memory
What does a virtual address point to?
Something that acts like memory
What do we call addresses accessed via the memory interface (load and store)?
Virtual addresses.
These virtual addresses point to something that acts like memory, but is really an address that needs to be translated into a corresponding physical address
What are the 4 locations that data referred to by a virtual address might be?
In memory, on disk, in memory on another machine, or at a port on a hardware device
What expectations does a process have about the permanence of a store at a particular virtual address?
It depends on where the virtual address points to.
If it points to physical memory, it expects the data to be stored transiently (temporarily).
If it points to the disk, it expects the data to be stored permanently.
If it points to a device port, then it will depend on how the device.
What permissions and protections come with virtual addresses?
Some virtual addresses may only be used by the kernel.
Virtual addresses can be assigned read, write, or execute permissions.
How are virtual addresses created and initialized by exec()?
Exec() uses a blueprint from an ELF file to determine how the address space should look.
Virtual addresses (mainly) point to memory. Specifically:
Code is usually marked read-only
Data is marked read-write, but not executable
Heap is given an area used for dynamic allocations and marked read-write
Stack space is provided for the first thread
What does fork() do to the address space of the calling process?
It creates a copy of it for the child. This means in physical memory, there are two copies of the objects from the original process.
The child has the same virtual addresses as the parent, but they point to different physical memory locations (their own corresponding copies of the data)