📝 Memory Swapping on mobile systems (9 MCQs)
Memory Reclamation in Smartphones and Mobile Operating Systems
Memory swapping on mobile systems concerns techniques used to manage limited physical RAM while applications compete for available memory. Unlike traditional desktop swapping, mobile operating systems frequently combine memory compression, page reclamation, background-process management, and application termination. These approaches preserve responsiveness, battery life, and storage endurance. Their exact implementation differs across platforms, device manufacturers, operating system versions, and available hardware resources.
Why Mobile Devices Use Different Memory Policies
Smartphones operate under tighter power, thermal, storage, and memory constraints than many desktop computers. Flash storage is slower than RAM and has finite write endurance, making continuous conventional swapping undesirable. Background applications also need predictable responsiveness when users return to them. Mobile operating systems therefore reclaim memory selectively and may sacrifice inactive processes rather than repeatedly transferring entire process images.
Compression, Reclaim and Application Termination
A mobile memory manager identifies memory pages that can be reclaimed or compressed. Systems using compressed swap, such as Android configurations with zRAM, store compressed pages in a reserved region of RAM. Other policies may discard clean file-backed pages or terminate selected background processes. When an application resumes, its data is restored, reloaded, or reconstructed according to its saved state and platform implementation.
Managing Memory When Several Apps Remain Open
Suppose a phone has 6 GB of physical RAM and several applications occupy most of it. When a camera application needs additional memory, the operating system may compress eligible background pages or reclaim cached file data. If memory remains insufficient, it may terminate a less important background process. Returning to that application may require restarting it or restoring saved application state.
Battery Life, Flash Endurance and Background Responsiveness
Compression can reduce storage traffic and retain more application data in available RAM, but decompression consumes processor time and energy. Flash-backed swapping may provide additional capacity, yet frequent writes can increase latency, power consumption, and device wear. Application termination frees memory promptly but may increase restart delays. Mobile systems balance these costs according to workload, memory pressure, and platform-specific policies.
Platform Differences and Misleading Swap Assumptions
'Every smartphone uses conventional disk swapping' is incorrect because mobile platforms use different combinations of compression and process reclamation. 'zRAM stores compressed pages on flash storage' is incorrect because zRAM provides compressed block storage in RAM. 'Terminating a background app always loses all user data' is incorrect because applications can save state persistently before termination, depending on their design and operating system support.
Exam Focus: Compression, Reclamation and Process Lifecycle
Compare conventional swapping, compressed memory, page reclamation, and background-process termination. Explain why mobile systems consider battery consumption and flash endurance alongside memory capacity. Trace how memory pressure can cause application compression, page reclamation, or process termination. Avoid assuming that every mobile operating system follows identical policies or uses the same swap configuration.
Key Terms of Mobile Memory Management
- zRAM - Compressed block storage in RAM.
- Memory pressure - Demand exceeding available memory.
- Compression - Reduces stored page size.
- Page reclamation - Recovers reusable memory pages.
- Flash endurance - Capacity to tolerate writes.
- Background process - Application process not foregrounded.
📝 All Memory Swapping on mobile systems MCQs
Q1. What is swapping in mobile operating systems?
📖 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?
📖 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?
📖 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?
📖 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?
📖 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?
📖 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?
📖 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?
📖 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?
📖 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.