๐ Protection in Paging (11 MCQs)
Page-Level Access Control in Virtual Memory
Protection in paging is a memory-management facility that controls which operations a process can perform on individual virtual memory pages. The operating system records access permissions in page-table entries, and the MMU checks those permissions during translation. Common controls distinguish read, write, and execute access, as well as privileged and user-mode access. This mechanism isolates processes and prevents unauthorized modification or execution of protected memory.
Why Each Page Requires Explicit Access Permissions
Address translation alone does not guarantee security because a valid mapping could still allow an application to access sensitive data or modify executable code. Page-level protection separates memory accessibility from memory location. It allows the operating system to enforce different rules for code, data, kernel memory, and shared regions. Protection attributes also help implement safe execution environments and controlled memory sharing.
Permission Checks During a Page-Table Lookup
When the CPU issues a memory reference, the MMU obtains the relevant page-table entry and checks its permission bits. The processor verifies that the operation is permitted for the current privilege level. For example, a user-mode write to a read-only page is rejected. Depending on mapping state and architecture, the invalid access generates a page fault or protection exception for kernel handling.
Preventing a User Process from Modifying Code Pages
Suppose a process has a code page mapped with read and execute permissions but without write permission. Instruction fetching and permitted reading can proceed normally. When the process attempts to modify that page, the MMU detects the prohibited write and raises a protection fault. The operating system can reject the access rather than allowing executable instructions to be overwritten.
Security Benefits and Permission-Management Costs
Page-level protection helps enforce process isolation, kernel confidentiality, executable-code integrity, and controlled shared memory. Modern processors may also support execute-disable attributes and detailed access controls. However, incorrect permission settings can cause faults or expose sensitive information. The operating system must maintain page-table attributes consistently during process creation, memory mapping, and changes to memory-protection policies.
Distinguishing Missing Pages from Forbidden Access
'Every page fault means the address is invalid' is incorrect because a valid virtual page may simply need to be brought into memory. 'Read-only pages cannot be read' is incorrect because read permission specifically allows reading while prohibiting writes. 'User-mode programs can freely modify kernel page permissions' is incorrect because page-table management requires privileged operating system control.
Exam Focus: Read, Write and Execute Permission Checks
Given a page-table entry and memory operation, determine whether access is permitted for the current privilege level. Compare present or valid status with read, write, and execute permissions. Explain why an absent page may produce a recoverable page fault while a prohibited operation causes an access violation. Trace how the kernel handles these exceptions.
Key Terms of Paging Protection
- Read permission - Allows reading page contents.
- Write permission - Allows modifying page contents.
- Execute permission - Allows instruction execution.
- Privilege level - Determines access authority.
- Protection fault - Reports prohibited memory access.
- NX bit - Disables instruction execution.
๐ All Protection in Paging MCQs
Q1. What is the primary purpose of a limit register in a protected memory system?
๐ Explanation: The limit register defines the upper bound of a processโs logical address space, so any address larger than this limit is invalid. This prevents a process from reading or writing outside its allotted memory. Options A and C describe the relocation (base) register and address translation, while D is unrelated to memory protection. Understanding the limit registerโs role is essential for enforcing isolation between processes.
Q2. A process attempts to read a logical address that exceeds its limit register value. What will the hardware typically do?
๐ Explanation: When a logical address is outside the range defined by the limit register, the MMU detects the violation and signals a fault, usually a segmentation fault. This stops the process from accessing unauthorized memory. Option A ignores the limit check, Option C would break protection guarantees, and Option D is not how modern systems allocate memory dynamically. The fault mechanism safeguards system stability.
Q3. Why are both a relocation (base) register and a limit register needed for effective memory protection?
๐ Explanation: The relocation (base) register translates a processโs logical addresses to physical addresses by adding a constant offset, establishing where the process begins in memory. The limit register then caps the highest logical address the process may use, ensuring it cannot exceed its allocated region. Options A and C misunderstand their distinct roles, and D describes a function not related to basic protection. Together they give both location and bounds, essential for isolating processes.
Q4. Given a relocation register value of 100040 and a limit register of 74600, what physical address corresponds to logical address 50000?
๐ Explanation: The physical address is calculated by adding the relocation base to the logical address: . This translation places the logical address within the processโs allocated memory region. Option B adds the limit incorrectly, Option C ignores the logical offset, and Option D mistakenly uses the limit as the physical address. This simple arithmetic illustrates how base registers map a processโs address space to actual memory locations.
Q5. How does a limit register enforce memory bounds for a running process?
๐ Explanation: Before the MMU translates a logical address, it compares the address with the limit register. If the address exceeds the limit, the access is denied and a fault is raised. This check ensures a process cannot stray beyond its allocated region. Options B and C misrepresent the function of the limit register, and D is unrelated to memory protection. The bound check is a core safeguard in multitasking environments.
Q6. If a system administrator mistakenly sets a processโs limit register to a value larger than its actual memory allocation, what risk does this create?
๐ Explanation: An oversized limit register removes the boundary that isolates a process, allowing it to access physical addresses that belong to other processes or the kernel. This can lead to data corruption, security breaches, or system instability. Options B and C underestimate the security implications, and D is extreme; the OS typically continues running but the protection is compromised. Proper limit settings are vital for safe multitasking.
Q7. What does the acronym MMU stand for in computer architecture?
๐ Explanation: The MMU is the hardware component that handles address translation, mapping logical (virtual) addresses to physical memory locations and enforcing protection checks. Options B, C, and D are plausible-sounding but incorrect expansions. Knowing the correct term is fundamental for discussing how computers isolate processes and manage memory efficiently.
Q8. In a system with several concurrent processes, each process is given its own relocation register value. How does this design help prevent one process from interfering with another's memory?
๐ Explanation: Assigning a distinct base (relocation) value to each process shifts its logical address space to a separate physical region, ensuring that even if two processes use the same logical address, the resulting physical addresses differ. This separation prevents accidental or malicious memory overlap. Options A and C negate the protective effect, while D misunderstands the role of limit registers, which still define each processโs range.
Q9. How does segmentation differ from a simple base/limit (relocation) scheme in terms of protection and flexibility?
๐ Explanation: Segmentation divides a programโs address space into named segments (code, data, stack), each with its own base and limit, allowing different sized regions and independent protection checks. A simple base/limit scheme uses one contiguous range, limiting flexibility. Option A reverses the characteristics, Option B incorrectly claims segmentation lacks protection, and Option D ignores the distinct mechanisms. Segmentation thus enhances both security and adaptability.
Q10. A program attempts to write to a logical address that is exactly one byte beyond its limit register value. Which hardware component will detect this violation?
๐ Explanation: The MMU performs the bound check against the limit register before allowing a write. When the address exceeds the limit, the MMU raises a fault, preventing the illegal write. The ALU processes arithmetic operations, the cache controller manages cached data, and the GPU handles graphics; none are responsible for memory protection checks. This detection is crucial for maintaining process isolation.
Q11. If a programโs base address (relocation register) is changed after it has been loaded into memory, what effect does this have on address translation?
๐ Explanation: Changing the relocation register updates the offset added to every logical address, so each address now maps to a different physical location. This allows the operating system to move a program in memory without altering its internal code. Options B and D contradict the fundamental role of the base register, and C misstates the continued need for a limit to enforce bounds. Properly updating the base ensures continued protection and correct operation.