OS Notes
A comprehensive study of the Android operating system architecture, its Linux kernel foundation, application framework, and how it manages mobile device resources efficiently.
Introduction
If you are reading this on a smartphone, there is a good chance it is running Android. With over 3.5 billion active devices worldwide, Android is the most widely used operating system on the planet. But have you ever wondered what happens behind the scenes when you tap an app icon, or how your phone manages to run multiple apps without crashing?
Android is not just a user interface with colorful icons. It is a complete, sophisticated operating system built on top of the Linux kernel, designed specifically for touchscreen mobile devices. Understanding Android's architecture gives you insights into how operating system concepts like process management, memory handling, and security work in the real world — right in your pocket.
History and Evolution
Android was originally developed by Android Inc., a startup founded by Andy Rubin in 2003. Google acquired Android Inc. in 2005 and released the first commercial Android device in 2008 (the HTC Dream/T-Mobile G1). Since then, Android has evolved through numerous versions, each named after desserts until Android 10 when Google switched to simple numbers.
The key philosophy behind Android was openness. Unlike iOS, Android is open-source (through the Android Open Source Project or AOSP), which means manufacturers like Samsung, Xiaomi, and OnePlus can customize it for their devices. This openness is why Android runs on everything from phones to TVs, cars, and even refrigerators.
Android Architecture — Layer by Layer
Think of Android as a layered cake. Each layer builds upon the one below it, providing higher-level services:
Layer 1: Linux Kernel
At the very bottom, Android uses a modified Linux kernel. This provides core OS services like process management, memory management, device drivers, and security. However, Android's kernel includes several additions not found in standard Linux — most notably the Binder IPC mechanism for inter-process communication between apps and a unique power management system called wakelocks.
Layer 2: Hardware Abstraction Layer (HAL)
The HAL sits between the kernel drivers and the higher-level framework. It provides standard interfaces that expose device hardware capabilities. For instance, a camera HAL defines how any camera hardware should respond to commands like "take a photo" or "start video recording," regardless of the actual camera chip installed.
Layer 3: Native Libraries and Android Runtime
This layer includes C/C++ libraries (SQLite for databases, OpenGL ES for graphics, WebKit for web rendering) and the Android Runtime (ART). Before Android 5.0, apps ran on the Dalvik Virtual Machine which used Just-In-Time (JIT) compilation. ART replaced Dalvik with Ahead-Of-Time (AOT) compilation, converting app bytecode to native machine code during installation for better performance.
Layer 4: Application Framework
This is the layer that app developers interact with most. It provides Java and Kotlin APIs for building apps, including the Activity Manager (manages app lifecycles), Window Manager (handles screen display), Content Providers (share data between apps), and the Notification Manager.
Layer 5: Applications
The top layer consists of both pre-installed system apps (Phone, Contacts, Settings) and user-installed apps from the Google Play Store.
Process and Memory Management in Android
Android handles processes differently from desktop Linux because mobile devices have limited RAM and battery life. Every Android app runs in its own process with its own instance of the ART virtual machine. This provides security isolation — one app cannot directly access another app's memory.
When memory runs low, Android uses a priority-based system called the Low Memory Killer (LMK). Processes are ranked by importance:
- Foreground process — The app currently on screen (highest priority, killed last)
- Visible process — Partially visible (like a dialog behind the foreground app)
- Service process — Running a background service (music player, download)
- Cached process — Previously used apps kept in memory for quick restart (killed first)
// Simplified representation of Android's process priority
// (actual implementation in kernel/drivers/staging/android/lowmemorykiller.c)
#define FOREGROUND_APP_ADJ 0
#define VISIBLE_APP_ADJ 1
#define PERCEPTIBLE_APP_ADJ 2
#define BACKUP_APP_ADJ 3
#define CACHED_APP_MIN_ADJ 9
// When free memory drops below threshold,
// kill processes starting from highest adj valueSecurity Model
Android's security is built on several layers. Each app gets a unique Linux user ID (UID), meaning apps are sandboxed at the OS level. The permission system requires apps to declare what resources they need (camera, location, contacts), and users must grant these permissions explicitly since Android 6.0.
SELinux (Security-Enhanced Linux) provides mandatory access control, preventing even root-level exploits from accessing protected system resources. Verified Boot ensures the device firmware has not been tampered with.
Binder IPC — Android's Communication Backbone
One of Android's most important innovations is the Binder IPC mechanism. When your music app needs to play audio, it does not directly access the speaker hardware. Instead, it sends a message through Binder to the AudioService, which then communicates with the audio HAL. This separation ensures security and stability — a buggy app cannot crash the audio system.
Think of Binder like a post office. Apps write messages (transactions), address them to a specific service, and Binder delivers them reliably. The receiving service processes the request and sends back a reply through the same mechanism.
Power Management
Mobile devices run on batteries, so power management is critical. Android uses wakelocks — a mechanism where apps or services can request the CPU to stay awake for critical tasks. The system also uses Doze mode (introduced in Android 6.0) which restricts background activity when the device is stationary and unplugged, dramatically extending battery life.
Real-World Analogy
Think of Android like a well-managed apartment building. The Linux kernel is the building's foundation and utilities (plumbing, electricity). The HAL is like the standardized outlets and fixtures. The framework is the building management office that handles requests. Each app is a tenant in their own apartment — they can decorate freely inside but cannot break through walls to access their neighbor's space. The Low Memory Killer is like the building manager asking short-term guests to leave when the building gets too crowded.
Key Takeaways
- Android is built on a modified Linux kernel, making it technically a Linux distribution
- The layered architecture separates concerns — kernel handles hardware, framework provides APIs, apps serve users
- Every app runs in its own sandboxed process with a unique user ID
- The Low Memory Killer manages limited mobile RAM by terminating low-priority processes
- Binder IPC enables secure communication between apps and system services
- ART replaced Dalvik with ahead-of-time compilation for better runtime performance
- Android's openness enables massive customization but creates fragmentation challenges
Exam Focus
Revise definitions, diagrams, examples, and short-answer points for Android Operating System — Operating Systems.
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, case, studies, android, system
Related Operating Systems Topics