OS Notes
Mobile Operating Systems — architecture of Android and iOS, mobile OS design challenges, process management, memory handling, power optimization, and security models in mobile platforms.
Introduction
Mobile operating systems power the most personal computers we own — our smartphones. These devices face unique challenges that desktop operating systems never encountered: battery life measured in hours not days, touchscreen interaction, cellular connectivity, GPS sensors, cameras, and strict security requirements because phones carry our most sensitive data. Mobile OS design is a masterclass in balancing performance, power efficiency, security, and user experience.
Over 6 billion smartphones exist worldwide, and virtually all run either Android or iOS. Understanding how these systems work reveals important OS principles applied to constrained, always-connected hardware.
Mobile OS Design Challenges
Mobile devices operate under constraints that shape every design decision:
Power: A 4000mAh battery must last all day. The OS aggressively manages which apps can run, suspends background processes, and negotiates with hardware for minimal power consumption.
Memory: Phones typically have 4-8 GB RAM shared among dozens of apps. No swap space (flash wear, performance). The OS must reclaim memory quickly by killing background apps.
Security: Phones store passwords, financial data, photos, messages, and location history. A compromised phone is far more dangerous than a compromised desktop.
Responsiveness: Touch interactions must feel instant. The UI thread must never block — any frame drop is immediately noticeable at 60-120 FPS.
Diverse Hardware: Android must run on thousands of different device configurations. Hardware abstraction is critical.
Android Architecture
Android is built on the Linux kernel with additional layers for mobile functionality:
Key Android Components
Linux Kernel: Provides process isolation (each app is a separate Linux process with unique UID), memory management, networking, and device drivers.
ART (Android Runtime): Executes app bytecode. Uses Ahead-of-Time (AOT) compilation during install plus Just-in-Time (JIT) compilation at runtime for optimization.
Binder IPC: Android's custom inter-process communication mechanism. Faster than traditional Unix pipes/sockets. All system service access goes through Binder (app → system server → hardware).
Activity Manager: Controls app lifecycle (created, started, resumed, paused, stopped, destroyed). Decides which apps live and which are killed for memory.
Android Process Lifecycle
Android categorizes processes by importance:
- Foreground: Currently interacting with user (highest priority, never killed)
- Visible: Visible but not in foreground (partially obscured)
- Service: Running background service (music player, download)
- Cached: Previously used, kept in memory for fast relaunch (killed first when memory needed)
When memory runs low, the Low Memory Killer (LMK) — based on Linux's OOM killer — terminates cached processes in priority order.
iOS Architecture
iOS uses a layered architecture built on Darwin (BSD-based kernel):
iOS Design Philosophy
Controlled environment: Apple controls hardware AND software. This enables tight optimization — iOS manages 4-6 GB RAM as efficiently as Android manages 8-12 GB.
No true multitasking for third-party apps: Background apps are suspended (frozen in memory). Only specific tasks (audio playback, location updates, VoIP) can run in background, and only briefly.
Memory management: iOS uses reference counting (ARC — Automatic Reference Counting) instead of garbage collection. Deterministic deallocation, no GC pauses.
Security Models
App Sandboxing
Both Android and iOS isolate each application:
Android:
- Each app runs as a separate Linux user (unique UID)
- Private data directory only accessible by that app
- Permissions declared in manifest, granted at runtime
- SELinux Mandatory Access Control enforces policies
iOS:
- Each app runs in its own sandbox directory
- Cannot access other apps' files or data
- Entitlements system controls access to system resources
- App Store review provides additional security gate
Permission Models
| - Camera | android.permission.CAMERA |
| - Location | android.permission.ACCESS_FINE_LOCATION |
| - Storage | android.permission.READ_EXTERNAL_STORAGE |
iOS uses similar runtime permission requests: camera, microphone, location, photos, contacts.
Memory Management on Mobile
Why No Swap Space?
Desktop operating systems use disk-based swap when RAM is full. Mobile OS cannot:
- Flash storage has limited write cycles — continuous swapping would degrade it
- Flash I/O is slow — swap would cause terrible user experience
- Better strategy: kill background apps and rely on fast app relaunch
Android Memory Management
- zRAM: Compresses inactive memory pages in RAM (no disk I/O)
- Low Memory Killer: Kills lowest-priority processes when memory pressure rises
- Trim memory callbacks: Apps receive hints to release caches before being killed
iOS Memory Management
- Jetsam: iOS's equivalent of OOM killer — terminates apps exceeding memory limits
- Memory warnings: Apps receive
didReceiveMemoryWarning()to release caches - Compressed memory: Like zRAM, compresses inactive pages in-place
Power Management
Battery life is the number one user complaint. Mobile OS employ aggressive strategies:
CPU Governors: Dynamically scale CPU frequency based on workload. big.LITTLE architecture routes light tasks to power-efficient cores, heavy tasks to performance cores.
Background Restrictions: Limit what apps can do when not visible:
- Android Doze mode: Batches network access and background work into maintenance windows
- iOS Background App Refresh: Apps get brief periodic wake-ups for updates
Display Management: Screen is the largest power consumer (30-50% of battery). OS adjusts brightness, supports dark mode (saves power on OLED), and turns off screen quickly.
Radio Management: Cellular, Wi-Fi, Bluetooth, GPS each consume significant power. OS batches network requests, uses cell towers for approximate location (saving GPS power), and monitors which radios are needed.
Comparison: Android vs iOS
| Feature | Android | iOS |
|---|---|---|
| Kernel | Linux | XNU (Mach + BSD) |
| Language | Java/Kotlin + C/C++ | Swift/Obj-C + C/C++ |
| App format | APK (DEX bytecode) | IPA (native ARM binary) |
| Multitasking | True (services, work manager) | Restricted (suspended background) |
| Memory strategy | Kill cached processes, zRAM | Jetsam, memory compression |
| App distribution | Play Store + sideloading | App Store only |
| Security | SELinux + sandboxing | Sandbox + code signing + review |
| Customization | High (launchers, defaults) | Low (Apple controls UX) |
Key Takeaways
- Mobile OS must balance performance, power, security, and responsiveness
- Both Android and iOS sandbox apps for security and stability
- Memory management relies on killing background apps rather than swapping
- Power management involves CPU frequency scaling, background restrictions, and radio control
- Android's openness provides flexibility; iOS's control provides optimization and security
- Mobile OS design principles increasingly influence desktop/server OS design
Exam Focus
Revise definitions, diagrams, examples, and short-answer points for Mobile Operating Systems - Android, iOS, and Windows.
Interview Use
Prepare one clear explanation, one practical example, and one common mistake for this Operating Systems topic.
Search Terms
operating-systems, operating systems, operating, systems, distributed, and, modern, mobile
Related Operating Systems Topics