0
0
Operating Systemsknowledge~10 mins

Page fault handling in Operating Systems - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to identify the cause of a page fault.

Operating Systems
if (error_code & [1]) {
    // Page fault caused by a write operation
}
Drag options to blanks, or click blank then click option'
A0x1
B0x4
C0x2
D0x8
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing the bit for read and write operations.
Using the wrong hexadecimal value for the error code bit.
2fill in blank
medium

Complete the code to check if the page fault was caused by a protection violation on a present page.

Operating Systems
if (error_code & [1]) {
    // Page present: protection fault
}
Drag options to blanks, or click blank then click option'
A0x1
B0x2
C0x4
D0x8
Attempts:
3 left
💡 Hint
Common Mistakes
Using the bit for write fault instead of page presence.
Misinterpreting the error code bits.
3fill in blank
hard

Fix the error in the code to correctly handle a page fault caused by user mode access.

Operating Systems
if (error_code & [1]) {
    // Fault caused in user mode
}
Drag options to blanks, or click blank then click option'
A0x4
B0x1
C0x2
D0x8
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing user mode bit with write or present bits.
Using incorrect hexadecimal values.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps page numbers to their status if the page is present and accessed in user mode.

Operating Systems
page_status = {page_num: status for page_num, status in pages.items() if (status & [1]) and (status & [2])}
Drag options to blanks, or click blank then click option'
A0x1
B0x2
C0x4
D0x8
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up bits for write and user mode.
Using bits that do not represent presence or user mode.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps virtual addresses to page numbers for pages that are present, writable, and accessed in user mode.

Operating Systems
virtual_to_page = {va: pa for va, (pa, flags) in memory_map.items() if (flags & [1]) and (flags & [2]) and (flags & [3])}
Drag options to blanks, or click blank then click option'
A0x1
B0x2
C0x4
D0x8
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing write bit with other bits.
Forgetting to check all three conditions.