Lecture 7 Flashcards

Address Translation and Paging (70 cards)

1
Q

What is address translation?

A

The process of converting a virtual address into a physical address.

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

What role does the OS play in address translation?

A

The OS must manage memory and intervene at key points to set up hardware for address translation.

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

What is a base and bounds register?

A

Registers used to define the limits of a process’s address space in memory.

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

What is dynamic relocation?

A

A technique where the OS can move address spaces even after a process has started running.

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

Fill in the blank: The physical address is calculated as _______.

A

virtual address + base

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

What happens when a process tries to access memory outside its bounds?

A

The CPU raises an exception, and the OS must handle it.

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

What is a free list in memory management?

A

A list that includes the size and location of physical memory that is not in use.

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

What is a page fault?

A

An exception that occurs when a program tries to access a page that is not currently in memory.

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

True or False: The OS installs exception handlers at boot time.

A

True

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

How does the CPU detect an invalid memory access?

A

The CPU sends the virtual address to the Memory Management Unit (MMU) for translation.

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

What does the MMU check when translating a virtual address?

A

It checks if the address is mapped and if the program has the right permissions.

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

What is memory fragmentation?

A

A condition where memory is divided into small, non-contiguous blocks, leading to inefficient usage.

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

When does the OS reclaim memory?

A

When a process is terminated.

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

What is the purpose of exception handlers in the OS?

A

To handle errors such as invalid memory access or page faults.

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

What happens during a context switch?

A

The OS saves and restores the base-and-bounds pair for different processes.

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

What is the role of privileged instructions in address translation?

A

They allow the OS to set base/bounds values and handle exceptions.

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

What is segmentation in memory management?

A

A technique used to address the issue of fragmentation.

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

Fill in the blank: The OS must find space for an address space when a process _______.

A

starts running

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

What does the OS do when a page fault occurs and the access is valid?

A

The OS loads the page from disk and returns to user space.

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

What are the two types of registers required for address translation?

A

Base register and bounds register.

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

What is the significance of the Interrupt Descriptor Table (IDT)?

A

It helps the CPU find the handler for page faults.

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

What is the consequence of accessing read-only memory?

A

It triggers a page fault due to permission violation.

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

What is fragmentation in memory allocation?

A

Fragmentation occurs when memory is divided into small, non-contiguous blocks, making it difficult to allocate large processes even when enough total memory is available.

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

What are the two main types of fragmentation?

A
  • Internal Fragmentation
  • External Fragmentation
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Define internal fragmentation.
Internal Fragmentation occurs when allocated memory is larger than needed.
26
Give an example of internal fragmentation.
If a process needs 450 KB, but the system allocates 512 KB blocks, then 62 KB is wasted inside the allocated block.
27
What causes internal fragmentation?
Fixed-size memory allocation (e.g., paging systems).
28
Define external fragmentation.
External Fragmentation occurs when free memory is available but in scattered, non-contiguous blocks.
29
Provide an example of external fragmentation.
Suppose a system has 600 KB of free memory split into three blocks of 200 KB each. If a process needs 500 KB, it cannot be allocated despite sufficient total memory.
30
What causes external fragmentation?
Dynamic allocation of variable-sized blocks (e.g., Base and Bound).
31
What are the consequences of fragmentation?
* Inefficient use of memory * Potentially causing a system to run out of memory for new allocations earlier than necessary * Slower performance due to additional memory management operations like compaction or paging/swapping
32
What is the purpose of memory compaction?
Rearranging memory to reduce fragmentation.
33
List some strategies operating systems use to minimize fragmentation.
* Using paging systems * Implementing sophisticated allocation algorithms (e.g., best fit, worst fit, first fit) * Supporting memory compaction
34
How does Base and Bound suffer from external fragmentation?
The Base and Bound memory management technique assigns a single contiguous block to each process, leading to gaps between allocated memory blocks as processes terminate and new ones are allocated.
35
What is memory segmentation?
Memory segmentation divides memory into multiple segments, such as code segment, stack segment, and heap segment.
36
How does segmentation reduce external fragmentation?
Segments can be placed non-contiguously, allowing smaller free spaces to be used efficiently.
37
What is the history of segmentation in operating systems?
* Early OS used segmentation. * Burroughs B5000 was the first commercial machine with virtual memory. * Intel CPUs (8086, 80286, 80386) support paging. * X86-64 does not use segmentation in 64-bit mode.
38
What is paging in memory management?
Paging splits up the process address space into fixed-sized units called pages.
39
What is the difference between segmentation and paging?
Segmentation has variable sizes of logical segments (code, stack, heap), while paging uses fixed-size units.
40
What is a page frame?
Physical memory is split into a number of pages called a page frame.
41
What is the purpose of a page table?
A page table is a data structure used to map the virtual address to the physical address.
42
What does the valid bit in a Page Table Entry (PTE) indicate?
It indicates whether the particular translation is valid or not (swapped or unassigned).
43
What does the protection bit in a PTE indicate?
It indicates whether the page could be read from (R), written to (W), or executed from (X).
44
What does the present bit in a PTE indicate?
It indicates whether this page is in physical memory or on disk (swapped out).
45
What is the dirty bit in a PTE?
It indicates whether the page has been modified since it was brought into memory.
46
What is the reference bit in a PTE?
It indicates that a page has been accessed for page replacement algorithms.
47
What is the simplest form of a page table?
A linear page table, which is just an array.
48
What happens when a page is swapped to disk?
Accessing it will trigger a page fault, and the OS will load it back into RAM.
49
How does the OS find the desired PTE?
The OS indexes the array by the virtual page number (VPN) and looks up the page-table entry (PTE) at that index.
50
What register is needed to find the starting location of the page table?
cr3 register
51
How many extra memory references does paging require for every memory reference?
one extra memory reference
52
What is the virtual address 21 in a 64-byte address space represented in binary?
010101
53
What does VPN stand for in memory addressing?
Virtual Page Number
54
How is the VPN derived from a virtual address?
VPN = (VirtualAddress & VPN_MASK) >> SHIFT
55
What is the formula to compute the address of the page-table entry (PTE)?
PTEAddr = PTBR + (VPN * sizeof(PTE))
56
What happens if the PTE is not valid during memory access?
RaiseException(SEGMENTATION_FAULT)
57
What is raised if access permissions in the PTE are insufficient?
RaiseException(PROTECTION_FAULT)
58
What is the formula to form the physical address from the PTE?
PhysAddr = (PTE.PFN << PFN_SHIFT) | offset
59
What does a memory trace generate during program execution?
two memory references
60
What is the major issue in memory allocation that fragmentation refers to?
External fragmentation
61
What method for memory protection suffers from fragmentation and inflexibility?
Base and Bound Registers
62
What does segmentation do to memory?
Divides memory into logical sections
63
What does paging eliminate in memory management?
External fragmentation
64
What do page tables store information about?
Memory pages, including access permissions
65
What is a page fault?
An invalid memory access handled by the OS
66
What optimizations improve performance in paging systems?
Multi-level paging and TLBs
67
Fill in the blank: The process of addressing translation involves the __________ to fetch the PTE.
page table
68
True or False: Paging requires variable-size pages to manage memory allocation effectively.
False
69
What is the purpose of the PTBR in memory management?
Page Table Base Register
70
What does PTE stand for?
Page Table Entry