Virtual Memory Flashcards

1
Q

VM was created to allow running ____.

A

processes with memory requirements larger than available RAM to run in the computer.

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

Currently, VM is used mainly to give each process its own address space.
True/False

A

True

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

VM only keeps in RAM the memory that is currently in use.

The remaining memory is kept in disk in a special file called ___.

A

Swap space

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

VM implementations:

Process swapping: The entire memory of the process is ___.

A

swapped in and out of memory

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

VM implementations:
Segment swapping:
___ are swapped in and out of memory (libraries, text, data, bss etc).

A

Entire parts of the program (process)

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

There are 3 VM implementations:
___ swapping
___ swapping
___

A

process; segment; paging

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

Which of the following about paging is false?
A. Paging is used by modern operating.
B. The unit of memory that is swapping in and out is a page.
C. Paging divides the memory in pages of different sizes.
D. Usually the size of a page is 4KB in x86.

A

C.

Paging divides the memory in pages of fixed size.

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

Paging:
The virtual memory system will keep in memory ___.
It will leave in disk ___.

A

the pages that are currently in use; the memory that is not in use

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

Each page in the address space is backed by a file in disk, called ___.

A

backing-store

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q
Name the backing store for the following memory section:
Text
ROData
Data
BSS
Stack
Heap
A

Exe file; exe file; exe file (not modified), swap space (modified); swap space; swap space; swap space

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q
Name the permissions (RWX) for the following memory section:
Text
ROData
Data
BSS
Stack
Heap
A

RX; R; R, RW; RW; RW; RW

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

Any section in memory that is not persistent and will go away when the process exits is stored in ___.

A

Swap space

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

___ translates virtual memory addresses to physical memory addresses.

A

Memory Management Unit (MMU)

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

___ memory addresses: the address that the CPU is using. Addresses used by programs are of this type.

A

Virtual

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

___ memory addresses: The addresses of RAM pages. This is the hardware addresses.

A

Physical

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

The MMU has a ___ that points to the current page table that will be used for the translation.

A

page table register

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

Every process shares a page table.

True/False

A

False.

Each process has its own page table.

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

The page table register is updated during ___.

The page table has the information of ___.

A

a context switch from one process to the other.

the memory ranges that are valid in a process.

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

Consecutive pages in virtual memory are consecutive pages in physical memory.
True/False

A

False.

Consecutive pages in virtual memory may correspond to non-consecutive pages in physical memory.

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

To prevent looking up the page table at every memory access, the most recent translations are stored in ___.

A

Translation Look-Aside buffer (TLB)

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

The TLB ___ the translation from ___ to ___ memory addresses.

A

speeds up; virtual; physical

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

A page fault is an interrupt generated by ___.

A

MMU

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

The VM address is divided into 2 parts:

  • ___ (higher 20 bits)
  • offset (lower 12 bits)
A

Page number; offset

24
Q

Both the page number and the offset is translated.

True/False

A

False.

Only the page number is translated. The offset remains the same.

25
Q

Modern architectures use a ____ page table to reduce the space needed.

A

Multi-level

26
Q

In a two level page table, the page number is divided into 2 parts: ___ page number and ___ page number.

A

First level; second level

27
Q

Which of the following about two level page tables is false?
A. Process always have a 1st level page table
B. Process always have a 4KB 2nd level page table
C. Both the 1st and 2nd level page tables use 4KB

A

B.

Second level page tables are allocated as needed.

28
Q

Page bits: The remaining __ bits are used to store the characteristics of the page.

A

12

29
Q

Describe the bit:
Resident bit
Modified bit
Access bit

A

Page is resident in RAM instead of swap space/file.
Page has been modified since the last time the bit was cleared. Set by MMU.
Page has been read since the last time the bit was cleared. Set by MMU.`

30
Q

If a CPU operation exceeds the permissions of a page, the MMU ____.
The interrupt may be translated into ___.

A
generate an interrupt (page fault). 
a signal (SEGV, SIGBUS) to the process.
31
Q

If a page is accesss and the page is not resident in RAM, the MMU ___. Then the kernel ___.

A

generates an interrupt to the kernel.

loads that page from disk.

32
Q

Types of page faults:
___ : page not in physical memory, it is in disk
___ : write or access permission violated

A

Page not resident; protection violation

33
Q

Sequence of processing a page fault:-

1. A program tries to read/write a location in memory that is in a ___ page.

A

non-resident

34
Q

Sequence of processing a page fault:-

2. The MMU tries to ___, and finds that ___. MMu generates ___.

A

look up the VM address; page is not resident using the resident bit; a page fault

35
Q

Sequence of processing a page fault:-

3. The CPU save ____ and ___ in the stack.

A

return address; register

36
Q

Sequence of processing a page fault:-

4. The CPU looks up the ___ that corresponds to the page fault in the ___ and jumps to this ___.

A

interrupt handler; interrupt vector; interrupt handler

37
Q

Sequence of processing a page fault:-
5. In the page fault handler, if the VM address corresponds to a page is not valid for this process, then generate ___.
Otherwise, the page has to be ___.

A

a SEGV signal to the process.

Loaded from disk.

38
Q

The default behavior for SEGV is to ___.

A

kill the process and dump core

39
Q

Sequence of processing a page fault:-
6. Find ___ in physical memory.
If there are no free pages, use ___.

A

free page;

One that is in use and write to disk if modified.

40
Q

Sequence of processing a page fault:-
7. Load the page from disk and ___.
Clear ___ and ___ bits.
Set ___ to 1.

A

update the page table with the address of the page replaced.
modified and access; resident bit

41
Q

Which of the following is false?
A. The page fault handler retries the offending instruction at the end of the page fault
B. the program knows that the page fault occurred

A

B.
The page fault is completely transparent to the program. The program will have no knowledge that the page fault occurred.

42
Q

The mmap() function established a mapping between ___ and ___.

A

process’s address space; a file or shared memory object

43
Q

Mmap returns ___ and it will be always aligned to a ___.

A

address of the memory mapping; page size

44
Q

If NULL is passed in the address parameter in mmap(), the OS will choose the address of the mapping.
True/False

A

True

45
Q

The mmaped file should have a length of smaller or the program gets a SEGV on access.
True/False

A

False.

The mmaped file should have a length of larger or the program gets a SEGV on access.

46
Q

Flags in mmap:
MAP_SHARED : changes in memory will be ___
MAP_PRIVATE : changes in memory will be ___ (__)
MAP_FIXED : force to use ___
MAP_NORESERVE : do not ___ in advance
MAP_ANON : do not use any ___

A
done in the file;
kept private and not reflected in the file (copy on write);
"addr" as is without changing;
reserve swap space;
fd
47
Q

Mmap parameters:

Offset has to be a multiple of ___.

A

a page size

48
Q

Which of the following about mmap is false?
A. Writing in memory of a memory-mapped file will always update the file in the disk.
B. Updating the disk will not happen immediately.
C. The OS will cache the change until it is necessary to flush changes.

A

A.

Writing in memory of a memory-mapped file will update the file in the disk (only with MAP_SHARED).

49
Q

VM also speeds up the execution of programs:-

  1. Mmap the ___ segment of an executable or shared library
  2. Mmap the ___ segment of the program
  3. Use of VM during ___ to copy memory of ___ into ___
  4. Allocate ___ and space for bss, stack and sbrk()
  5. ___`
A

text; data; fork, parent , child; zero-initialized memory; shared memory

50
Q

Initialily, mmap does not ___. Any pages will be loaded on ___.
Startup time is ___ because ___.
It also saves ___ because only the portions of the program that are needed will be in ___.

A

read any pages; on demand when they are accessed; fast, only the pages needed will be loaded instead of the entire program; RAM, RAM

51
Q

Physical pages where the text segment is stored is shared by multiple instances of the same program.
True/False

A

True

52
Q

During the oading of a program, the OS mmaps the data segment of the program.
Multiple instances of the same program will share ___ where the data segment is mapped as long as ___.
If a page is modified, the OS ___.

A

the same physical memory pages, the page is not modified;

will create a copy of the page and make the change in the copy

53
Q

After forking, the child gets a copy of ___.
Both parent and child share the same ___ as long as they are not modified.
When a page is modified by either parent or child, the OS ___.

A

memory of the parent; RAM pages (physical memory); creates a copy of the page in RAM and will do the modifications on the copy

54
Q

The copy on write in fork is accomplished by ___.
The OS will catch the modifications. During the page fault, the OS will ___.
Then it will ___.

A

Making the common pages read only; create a copy and update the page table of the writing process;retry the modify instruction

55
Q

Which of the following is false?
A. VM is used to allocate space for bss, stack and sbrk()
B. When allocating memory using sbrk or map with the MMAP_ANON falg, all the VM pages in this mapping will map to a single page in RAM that has 0s and is read only
C. When a page is modified, the OS will directly write into the page
D. Fast allocation; saves RAM

A

C.

When a page is modified, the OS creates a copy of the page (copy on write) and retries the modifying instruction.

56
Q

Processes may communicate using ___.
Both processes share the same ___.
A modification in one page by one process will be reflected by a change in ___.

A

shared memory; physical pages; the same page in the other process