🎓 BookMCQ
← Back to 8. Main Memory

📝 Memory Swapping on mobile systems (9 MCQs)

📖 From Operating System • 8. Main Memory • 9 questions available

What is Memory Swapping on mobile systems?

Definition:
Mobile swapping uses compressed memory or selective page eviction instead of full process swap due to limited flash endurance and absence of traditional backing store.

Example:
Android’s zRAM compresses inactive pages in RAM achieving effective capacity increase of 2×2\times without writing to slow eMMC storage.

Reason:
Flash memory has limited write cycles and high latency making traditional swapping impractical so compression preserves responsiveness and device longevity.

2
Easy
5
Medium
2
Hard

📝 All Memory Swapping on mobile systems MCQs

Q1. What is swapping in mobile operating systems?

A.Copying a file from internal storage to external storage
B.Moving a process's entire memory image to secondary storage and later restoring it ✅
C.Changing the CPU scheduling algorithm
D.Encrypting user data before transmission
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: Swapping means the OS moves a process's memory image from RAM to secondary storage, such as flash, when RAM is scarce, and later brings it back when the process is needed again. This allows more programs to appear to run concurrently on limited mobile memory. Options A, C, and D describe unrelated actions, so they are incorrect. Understanding swapping is essential for managing limited resources on phones.

Q2. Why do base and limit registers prevent a user program from modifying the operating system’s code or other users’ data?

A.They encrypt memory contents
B.They restrict the range of addresses a program can legally access ✅
C.They increase CPU clock speed
D.They enable multitasking
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: Base and limit registers define a contiguous address window that a user program may reference. Any address outside this window causes a hardware trap, stopping the program from reaching OS code or another user’s memory. This hardware enforcement works independently of software checks, so the OS can safely load programs without fearing accidental or malicious overwrites. Options A, C, and D describe unrelated mechanisms, making them wrong.

Q3. A mobile app attempts to write to address 0x7FFF that exceeds its limit register set to 0x7FF0. What will the CPU do?

A.Ignore the write
B.Overwrite OS memory
C.Redirect to a safe buffer
D.Generate a trap to the OS ✅
💡 Difficulty: medium | ✅ Correct: D

📖 Explanation: When the accessed address is greater than the limit value, the hardware detects the violation and raises an exception, transferring control to the operating system’s trap handler. The OS can then terminate or suspend the offending process. Ignoring the write or redirecting data would break protection, while overwriting OS memory would compromise system stability. Therefore, generating a trap is the correct response.

Q4. When should the mobile OS decide to swap out a background app to free RAM?

A.When the app's CPU usage exceeds 80%
B.When the app holds more than 10 MB of dirty pages ✅
C.When the device is connected to power
D.When the foreground app requests a new page and no free frames exist
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: Swapping is triggered by memory pressure, not CPU usage or power state. If a foreground process needs a page and the system lacks free frames, the OS selects a suitable background process to swap out, freeing space for the new page. Options A and C describe performance or power considerations, which do not directly cause swapping. Option B focuses on dirty pages, which may influence write‑back but not the decision to swap.

Q5. How does the requirement that privileged instructions execute only in kernel mode ensure that only the OS can load base and limit registers?

A.User programs can request the OS to set the registers
B.The CPU ignores any attempt to modify the registers outside kernel mode ✅
C.The OS can bypass hardware checks
D.Privileged instructions are encrypted
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: Privileged instructions are designed to be recognized by the CPU only when the processor is in kernel (supervisor) mode. When user‑mode code attempts such an instruction, the CPU raises an exception, preventing the operation. Because only the OS runs in kernel mode, it alone can execute the instruction that loads the base and limit registers, guaranteeing exclusive control. Options A, C, and D misrepresent how hardware enforces privilege, so they are incorrect.

Q6. During a context switch on a smartphone, which step may involve swapping a process’s memory to secondary storage?

A.Saving the CPU registers to a cache
B.Flushing the instruction pipeline
C.Storing the process’s page frames to flash memory ✅
D.Updating the scheduler’s priority list
💡 Difficulty: hard | ✅ Correct: C

📖 Explanation: A context switch saves the state of the outgoing process and loads the state of the incoming one. If the outgoing process’s pages are not resident in RAM, the OS may write those pages to flash (swap space) before releasing the frames, ensuring that memory can be reallocated. Saving registers to cache or flushing the pipeline are purely CPU‑level actions, and priority updates do not move memory. Thus, storing pages to flash is the correct step.

Q7. If an OS wants a user program to read a configuration file but not modify executable code, which protection mechanism should be used?

A.Base and limit registers with read‑only flag ✅
B.User‑mode only execution
C.Checksum verification
D.Dynamic linking
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: The base and limit registers define the allowable address range, and a read‑only attribute can be applied to that range, permitting reads while blocking writes. This protects the executable code from alteration while still allowing data access. Pure user‑mode execution does not distinguish between read and write permissions, checksums detect tampering after the fact, and dynamic linking concerns loading libraries, not memory protection.

Q8. What is the relationship between kernel mode and the ability to modify base and limit registers?

A.Only kernel mode can read the registers
B.Kernel mode can execute privileged instructions that write the registers
C.User mode can modify the registers with a special API
D.Both modes have equal access ✅
💡 Difficulty: medium | ✅ Correct: D

📖 Explanation: Kernel mode grants the CPU permission to execute privileged instructions, which include the commands that load or change base and limit registers. User mode lacks this privilege, so any attempt to alter the registers results in an exception. Therefore, only code running in kernel mode can successfully modify these registers. Options A and C incorrectly assign read or write capability, and option D misstates that both modes have equal access.

Q9. A smartphone with 2 GB RAM has three apps running: App X uses 800 MB, App Y uses 600 MB, and App Z uses 400 MB. The system needs to launch a new app requiring 500 MB. Which action is most appropriate?

A.Terminate App X
B.Swap out App Z ✅
C.Swap out App Y
D.Increase RAM capacity
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: The device currently has 2 GB (2000 MB) total, with 800 + 600 + 400 = 1800 MB used, leaving only 200 MB free. To obtain the needed 500 MB, the OS should swap out the smallest memory‑consuming background app, App Z (400 MB), which together with the existing free memory provides enough space. Terminating App X would free more memory but disrupt the user experience, while swapping App Y is unnecessary, and increasing RAM is not a runtime option.

🔗 Related Topics (MCQs)