Threading Models and Their Role in Enhancing Performance
Threading Models and Their Role in Enhancing Performance
CS 10 - Operating Systems
1st Semester 2024-2025
Title: Assignment 2
Topic: Threading in Operating Systems
Name of Student:
Date Accomplished:
Overview
Android OS, which is based on the Linux kernel, primarily uses kernel-level threads. These
threads are managed by the Linux kernel, providing support for true parallelism on multi-core
processors, and allowing threads to be scheduled independently by the operating system.
Android applications typically rely on Java-based threading but ultimately run as kernel-level
threads, allowing efficient management of CPU resources.
Kernel-Level Threads
In Android, threads created by applications are kernel-level threads. This means that
the operating system directly handles their execution and scheduling, rather than the
application itself managing them. Kernel-level threading allows Android to leverage the
underlying Linux kernel’s capabilities, enabling efficient multitasking and concurrency,
particularly on devices with multi-core processors.
Android provides several threading mechanisms and APIs tailored to its environment, each suited for
different purposes:
The AsyncTask class was a popular way to perform background operations and update
the UI in Android. It simplified background tasks, particularly when short-lived opera-
tions were needed. However, due to limitations with lifecycle management and perfor-
mance, AsyncTask has been deprecated in favor of alternatives like Executors and Work-
Manager.
Handlers and Looopers are integral to Android’s threading model. A looper prepares a
thread to run a message queue, enabling it to handle asynchronous tasks. The main UI
thread has a looper by default, which makes it responsive to user input. Handler objects
allow thread to send and process messages and runnable objects, enabling task to run
specific threads without directly creating new ones.
Executors
Executor is a high-level API between Thread and AsyncTask that can manage thread
pools to limit the number of concurrent threads. Executors provide pre-configured
thread pools, which are useful for executing time-controlled tasks. If we create a thread
for every task, it can overwhelm the CPU with threads.
applications with rich graphical content often require that complex tasks be computed within a time
limit. The limitation on the response time can often be achieved by performing some of the processing
duties on other cores of the device. This is because devices nowadays come with multi-core processors
that enable multi-threading and these applications support multi-threading. For instance, if two players
are playing a game of chess with a reasonable time limit, then to help with the computation of the next
move, each player’s device would process the chess board image using the available cores, thus
speeding up the process of making the next move.
Android’s threading model is highly versatile, enabling developers to build responsive, efficient,
and resource-friendly applications. By offering multiple APIs tailored to different use cases, An-
droid provides the tools necessary to manage background and foreground tasks in a way that en-
hances both application performance and user satisfaction.