13. Virtual Addresses Flashcards

1
Q

Where does the stack start and which direction does it grow?

A

The stack starts at the top of the address space and grows down

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Where does the heap start and which direction does it grow?

A

The heap starts towards the bottom of the address space and grows up

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Will the stack and the heap ever meet (grow into each other)?

A

Probably not. That would require the stack, heap, or both to be huge.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What 3 things are required to implement the address space abstraction?

A
  1. Address translation, meaning 0x100 for Process 1 is not the same location as 0x100 for Process 2
  2. Protection (privacy), meaning processes can only access their own address space
  3. Memory management, meaning the ability to have a greater sum of address spaces than the amount of physical memory on the machine
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How does the address space contain a level of indirection?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

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

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)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are the two components of the memory interface?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What does a physical address point to?

A

Physical memory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What does a virtual address point to?

A

Something that acts like memory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What do we call addresses accessed via the memory interface (load and store)?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What are the 4 locations that data referred to by a virtual address might be?

A

In memory, on disk, in memory on another machine, or at a port on a hardware device

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What expectations does a process have about the permanence of a store at a particular virtual address?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What permissions and protections come with virtual addresses?

A

Some virtual addresses may only be used by the kernel.

Virtual addresses can be assigned read, write, or execute permissions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How are virtual addresses created and initialized by exec()?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What does fork() do to the address space of the calling process?

A

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)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What does the sbrk() system call do?

A

Handles dynamic memory allocation.

sbrk() asks the kernel to move the break point, or the point at which the process heap ends

17
Q

What does the mmap() system call do?

A

Creates virtual addresses that map to a portion of a file

18
Q

In a 32-bit MIPS architecture, what is the full range of available addresses?

A

0x0 to 0xFFFFFFFF

19
Q

What are the 4 address regions in our OS161 version of MIPS?

A

0x0 - 0x7FFFFFFF are the process virtual addresses (2GB)

0x80000000 - 0x9FFFFFFF are the kernel direct-mapped addresses that are translated by subtracting 0x80000000 (512 MB, cached)

0xA0000000 - 0xBFFFFFFF are the kernel direct-mapped addresses (512 MB, uncached)

0xC0000000 - 0xFFFFFFFF are kernel virtual addresses, which are translated by the kernel (1 GB)

20
Q

What does the hardware memory management unit (MMU) do during virtual address translation?

A

It speeds the process of translation once the kernel has told it how to translate an address or according to architectural conventions (MMU is the mechanism)

21
Q

What does the OS memory management subsystem do during virtual address translation?

A

It manages translation policies by telling the MMU what to do

22
Q

When considering virtual address translation mechanism vs its policy, what is the larger goal?

A

To have the system follow established OS policies while involving the OS directly in the translation as little as possible (because it’s time consuming to trap into the kernel)