Understanding the Android Software Stack and Operating Systems
Understanding the Role of the Linux Kernel in the Android Software Stack
The Linux Kernel plays a central role in the Android software stack as the foundation layer that interacts directly with the hardware and provides basic services for all other software layers above it. It handles tasks such as memory management, process scheduling, device drivers, and hardware abstraction, which are essential for running applications and services in Android.
Role of the Linux Kernel in Android:
- Hardware Abstraction: The Linux Kernel provides an abstraction layer between the hardware (like CPU, memory, sensors, and network interfaces) and the software above it. This ensures that software doesn’t need to interact directly with the hardware, making Android more portable across different devices.
- System Resources Management: The kernel manages essential system resources like memory, processors, and I/O. It allocates memory to apps, schedules CPU tasks, and handles input/output requests for peripherals (like touchscreens, cameras, etc.).
- Device Drivers: It includes drivers for different hardware components like touchscreen, Wi-Fi, Bluetooth, audio, and more. These drivers allow Android to communicate with hardware components efficiently.
- Security and Permissions: The kernel is responsible for managing access to resources and ensuring security by enforcing user permissions and preventing apps from accessing each other’s private data.
- Communication: It provides mechanisms for communication between different layers of the Android software stack, such as Inter-Process Communication (IPC) mechanisms like message queues, semaphores, and shared memory.
Interrupts and Interrupt Handling
An interrupt transfers control to the interrupt service routine, generally through the interrupt vector, which contains the addresses of all the service routines. The interrupt architecture must save the address of the interrupted instruction (and the state of registers if about to change). Incoming interrupts are disabled while another interrupt is being processed to prevent a lost interrupt. A trap is a software-generated interrupt caused either by an error or a user request. An operating system is interrupt-driven.
The operating system preserves the state of the CPU by storing registers and the program counter. It determines which type of interrupt has occurred:
- Polling
- Vectored interrupt system
Separate segments of code determine what action should be taken for each type of interrupt.
Computer System Categorization According to the Number of Processors
1. Single-Processor Systems
- Use a single processor
- One main CPU executing a general-purpose instruction set
- All systems have other special-purpose processors
- Device-specific processors (disk, keyboard, and graphics controllers)
- Run a limited instruction set and not user processes
- Disk controller à Disk scheduling
2. Multiprocessor Systems
Also known as parallel systems, tightly-coupled systems
Advantages include:
- Increased throughput
- Economy of scale
- Increased reliability – graceful degradation or fault tolerance
- Ex. HP NonStop System (Tandem) – Multiple CPU pairs working in lockstep
Types:
- Asymmetric Multiprocessing
- Master-slave relationship
- Each processor is assigned a specific task
- Master processor schedules & allocates work
- Ex. SunOS Version 4
3. Clustered Systems
- Like multiprocessor systems, but multiple systems working together
- Two or more systems coupled together
- High-availability of service
- Cluster Software runs on cluster nodes
- Usually sharing storage via a storage-area network (SAN)
- Provides a high-availability service which survives failures
- Asymmetric clustering has one machine in hot-standby mode
- Symmetric clustering has multiple nodes running applications, monitoring each other
- Some clusters are for high-performance computing (HPC)
- Applications must be written to use parallelization
Types of Operating Systems
1. Batch OS
- Requires program, data, and commands in the form of a job
- Allows little or no interaction between users and executing programs
- Greater resource utilization
- Not convenient due to turnaround delays and offline debugging
- Programs that do not require interaction
- Ex. Payroll, Forecasting, statistical analysis
- Scheduling is very simple
- Jobs served in FCFS form
- Memory Management very simple
- Divided into two parts
- One occupied by OS permanently
- Other used to load transient programs
Multiprogramming OS
- Improved throughput and resource utilization
- Multiplex resources of a computer system among a multitude of active programs
- Program in execution à Process or Task
- Support concurrent execution of two or more active processes
- Implemented by maintaining code & data simultaneously in memory
- H/w and S/w support for memory protection and concurrency control
Multiuser System
- Maintenance of individual user environment
- User authentication
- Resource usage accounting
Multi-access System
- Simultaneous access to a computer system through two or more terminals
- Ex. Airline ticket reservation
Multiprocessing or Multiprocessor System
- By definition its Multitasking
- Support simultaneous execution of multiple tasks on different systems
- OS monitors all active programs and system resources
Time-sharing Systems
- Representative of a multi-programmed, multiuser system
- Time-sharing
- Time-slicing (Round robin) scheduling
- File management must provide protection and access control
Real-time systems
- Used where a large number of events are processed in a short time
- Ex. Industrial control, Flight control, and real-time simulation
- Goal: Quick event-response times and meet scheduling deadlines
- Hard real-time systems
- Guarantee that critical tasks complete on time
- Secondary storage is limited or missing with data stored in ROM
- Soft real-time systems
- Less restrictive
- Expected to process thousands of interrupts without missing a single event
- Multitasking operations achieved through process scheduling
- High and Low priority process
- Process preemption
- Memory Management
- Process resides in memory permanently for quick response
- Little moving of programs between primary and secondary memory
Distributed OS
- Collection of autonomous computer systems capable of communication and cooperation via H/w and S/w
- Evolved from computer networks
- Transparency à Resources are hidden from the user
- System-wise sharing of resources (Files, I/O)
- Increased computation speed, functionality, data availability, and reliability
- Facilitates access to remote resources
System Calls
- Provides an interface to the services made available by OS
- How OS makes system calls available?
- Ex. Program of File Handling
- OS executes thousands of system calls/second
- Process control
- end, abort
- load, execute
- create process, terminate process
- get process attributes, set process attributes
- wait for time
- wait event, signal event
- allocate and free memory
- File management
- create file, delete file
- open, close file
- read, write, reposition
- get and set file attributes
- Device management
- request device, release device
- read, write, reposition
- get device attributes, set device attributes
- logically attach or detach devices
- Information maintenance
- get time or date, set time or date
- get system data, set system data
- get and set process, file, or device attributes
- Communications
- create, delete communication connection
- send, receive messages
- transfer status information
- attach and detach remote devices
