Lecture 7 Flashcards

Address Translation and Paging

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
Q

Define internal fragmentation.

A

Internal Fragmentation occurs when allocated memory is larger than needed.

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

Give an example of internal fragmentation.

A

If a process needs 450 KB, but the system allocates 512 KB blocks, then 62 KB is wasted inside the allocated block.

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

What causes internal fragmentation?

A

Fixed-size memory allocation (e.g., paging systems).

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

Define external fragmentation.

A

External Fragmentation occurs when free memory is available but in scattered, non-contiguous blocks.

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

Provide an example of external fragmentation.

A

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
Q

What causes external fragmentation?

A

Dynamic allocation of variable-sized blocks (e.g., Base and Bound).

31
Q

What are the consequences of fragmentation?

A
  • 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
Q

What is the purpose of memory compaction?

A

Rearranging memory to reduce fragmentation.

33
Q

List some strategies operating systems use to minimize fragmentation.

A
  • Using paging systems
  • Implementing sophisticated allocation algorithms (e.g., best fit, worst fit, first fit)
  • Supporting memory compaction
34
Q

How does Base and Bound suffer from external fragmentation?

A

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
Q

What is memory segmentation?

A

Memory segmentation divides memory into multiple segments, such as code segment, stack segment, and heap segment.

36
Q

How does segmentation reduce external fragmentation?

A

Segments can be placed non-contiguously, allowing smaller free spaces to be used efficiently.

37
Q

What is the history of segmentation in operating systems?

A
  • 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
Q

What is paging in memory management?

A

Paging splits up the process address space into fixed-sized units called pages.

39
Q

What is the difference between segmentation and paging?

A

Segmentation has variable sizes of logical segments (code, stack, heap), while paging uses fixed-size units.

40
Q

What is a page frame?

A

Physical memory is split into a number of pages called a page frame.

41
Q

What is the purpose of a page table?

A

A page table is a data structure used to map the virtual address to the physical address.

42
Q

What does the valid bit in a Page Table Entry (PTE) indicate?

A

It indicates whether the particular translation is valid or not (swapped or unassigned).

43
Q

What does the protection bit in a PTE indicate?

A

It indicates whether the page could be read from (R), written to (W), or executed from (X).

44
Q

What does the present bit in a PTE indicate?

A

It indicates whether this page is in physical memory or on disk (swapped out).

45
Q

What is the dirty bit in a PTE?

A

It indicates whether the page has been modified since it was brought into memory.

46
Q

What is the reference bit in a PTE?

A

It indicates that a page has been accessed for page replacement algorithms.

47
Q

What is the simplest form of a page table?

A

A linear page table, which is just an array.

48
Q

What happens when a page is swapped to disk?

A

Accessing it will trigger a page fault, and the OS will load it back into RAM.

49
Q

How does the OS find the desired PTE?

A

The OS indexes the array by the virtual page number (VPN) and looks up the page-table entry (PTE) at that index.

50
Q

What register is needed to find the starting location of the page table?

A

cr3 register

51
Q

How many extra memory references does paging require for every memory reference?

A

one extra memory reference

52
Q

What is the virtual address 21 in a 64-byte address space represented in binary?

53
Q

What does VPN stand for in memory addressing?

A

Virtual Page Number

54
Q

How is the VPN derived from a virtual address?

A

VPN = (VirtualAddress & VPN_MASK)&raquo_space; SHIFT

55
Q

What is the formula to compute the address of the page-table entry (PTE)?

A

PTEAddr = PTBR + (VPN * sizeof(PTE))

56
Q

What happens if the PTE is not valid during memory access?

A

RaiseException(SEGMENTATION_FAULT)

57
Q

What is raised if access permissions in the PTE are insufficient?

A

RaiseException(PROTECTION_FAULT)

58
Q

What is the formula to form the physical address from the PTE?

A

PhysAddr = (PTE.PFN &laquo_space;PFN_SHIFT) | offset

59
Q

What does a memory trace generate during program execution?

A

two memory references

60
Q

What is the major issue in memory allocation that fragmentation refers to?

A

External fragmentation

61
Q

What method for memory protection suffers from fragmentation and inflexibility?

A

Base and Bound Registers

62
Q

What does segmentation do to memory?

A

Divides memory into logical sections

63
Q

What does paging eliminate in memory management?

A

External fragmentation

64
Q

What do page tables store information about?

A

Memory pages, including access permissions

65
Q

What is a page fault?

A

An invalid memory access handled by the OS

66
Q

What optimizations improve performance in paging systems?

A

Multi-level paging and TLBs

67
Q

Fill in the blank: The process of addressing translation involves the __________ to fetch the PTE.

A

page table

68
Q

True or False: Paging requires variable-size pages to manage memory allocation effectively.

69
Q

What is the purpose of the PTBR in memory management?

A

Page Table Base Register

70
Q

What does PTE stand for?

A

Page Table Entry