Chapter 9+10 Flashcards

(34 cards)

1
Q

What is difference between logical and physical addresses?

A

Logical address: generated by CPU during program execution (virtual address). Physical address: actual location in physical memory. MMU translates logical to physical addresses.

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

Why are page sizes always powers of 2?

A

Makes address translation efficient using bit shifting. Page number = address&raquo_space; offset_bits. Offset = address & (page_size - 1).

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

What happens when two page table entries point to same frame?

A

Creates shared memory between processes. Useful for copying large memory quickly - both pages reference same physical memory. Update in one page visible in other page.

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

How many bits in logical address for 64 pages of 1024 words?

A

16 bits total. 6 bits for page number (2^6 = 64 pages). 10 bits for offset (2^10 = 1024 words per page).

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

How many bits in physical address for 32 frames of 1024 words?

A

15 bits total. 5 bits for frame number (2^5 = 32 frames). 10 bits for offset (same as page size).

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

How do first-fit best-fit worst-fit algorithms work?

A

First-fit: allocate in first partition large enough. Best-fit: allocate in smallest partition that fits. Worst-fit: allocate in largest available partition.

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

How to calculate page number and offset for address 3085 with 1KB pages?

A

Page size = 1024 bytes. Page number = 3085 / 1024 = 3. Offset = 3085 % 1024 = 13. Address 3085 is on page 3 offset 13.

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

How many entries in single-level page table for 21-bit virtual address?

A

2^21 / 2^11 = 2^10 = 1024 entries (21-bit address 11-bit page size = 10-bit page number).

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

How many entries in inverted page table?

A

One entry per physical frame. With 16-bit physical address and 2KB pages: 2^16 / 2^11 = 32 entries.

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

What is difference between internal and external fragmentation?

A

Internal: wasted space within allocated memory block (unused space in page). External: free memory exists but not contiguous enough for allocation.

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

What is required for dynamic memory allocation in contiguous allocation?

A

Must be able to expand process memory region. Requires free space adjacent to current allocation or ability to relocate entire process.

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

What is required for dynamic memory allocation in paging?

A

Allocate additional pages as needed. Page table grows to include new pages. No need for contiguous physical memory.

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

Why don’t mobile OS support swapping?

A

Limited storage speed (flash memory wear). Battery life concerns from frequent disk I/O. Solid state storage has limited write cycles. Better to terminate processes.

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

When do page faults occur?

A

When referenced page not in physical memory. Page table entry marked invalid or not present. Hardware generates page fault interrupt.

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

What actions does OS take during page fault?

A

Save process state. Determine which page caused fault. Check if reference is valid. Find free frame or use page replacement. Load page from storage. Update page table. Resume process.

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

What is minimum number of page faults for any algorithm?

A

At least n page faults where n is number of distinct pages in reference string (cold start misses).

17
Q

What is maximum number of page faults for any algorithm?

A

At most p page faults where p is length of reference string (worst case: every reference is a fault).

18
Q

Rank page replacement algorithms from bad to good.

A

FIFO (suffers Belady’s anomaly) < LRU (no Belady’s anomaly) < Optimal (no Belady’s anomaly best possible).

19
Q

How does locality of reference affect page faults?

A

Good locality: recently referenced pages likely to be referenced again reducing page faults. Poor locality: random access pattern causes more page faults.

20
Q

Why does column-major array access cause more page faults?

A

Accesses elements far apart in memory. Each array row may be on different page. Row-major access has better locality staying within same page longer.

21
Q

How many page faults occur in reference string analysis?

A

Depends on number of frames and replacement algorithm. LRU and FIFO may have different fault counts. Optimal always has minimum possible faults.

22
Q

Does Belady’s anomaly indicate non-optimal algorithm?

A

Yes. Optimal algorithms cannot have Belady’s anomaly. If algorithm shows more page faults with more frames it cannot be optimal.

23
Q

What does CPU 13% disk 97% utilization indicate?

A

Thrashing: excessive paging. Processes spend more time waiting for pages than executing. Decrease multiprogramming degree.

24
Q

What does CPU 87% disk 3% utilization indicate?

A

Good balance: CPU busy but minimal paging. Can possibly increase multiprogramming degree to use more CPU.

25
What does CPU 13% disk 3% utilization indicate?
Underutilization: processes may be I/O bound or waiting for other resources. Paging not the bottleneck. May increase multiprogramming.
26
Can page table simulate base and limit registers?
Yes. Set up page table so all valid pages are contiguous starting from base address. Set pages beyond limit as invalid.
27
How does address translation work with page tables?
Split virtual address into page number and offset. Use page number as index into page table. Get frame number from page table entry. Combine frame number and offset for physical address.
28
What is Translation Lookaside Buffer (TLB)?
Hardware cache for page table entries. Stores recent address translations. Much faster than accessing page table in memory. Improves address translation performance.
29
What causes TLB miss?
Referenced page not found in TLB cache. Must access page table in memory to get translation. More expensive than TLB hit.
30
How does multi-level page table work?
Break page number into multiple parts. Each part indexes into different level of page table. Reduces page table size for sparse address spaces.
31
What is page table entry structure?
Contains frame number valid bit dirty bit reference bit protection bits. May include other control bits depending on architecture.
32
How does copy-on-write work?
Parent and child initially share same physical pages. Pages marked read-only. When either process writes to page OS copies page and updates page tables.
33
What is demand paging?
Load pages only when referenced. Start process with no pages in memory. Generate page faults and load pages as needed. Reduces initial loading time.
34
How does page replacement algorithm selection affect performance?
FIFO: simple but may replace frequently used pages. LRU: better performance but more complex. Optimal: best performance but requires future knowledge.