Let’s briefly examine Android’s architecture from the bottom up. This figure show how’s a simplified representation of the Android stack.

Untitled

Linux Kernel

Android is built on top of the Linux kernel. As in any Unix system, the kernel provides drivers for hardware, networking, filesystem access, and process management. The Android kernel is slightly different from a “regular” Linux kernel that you might find on a desktop machine or a non-Android embedded device. The differences are due to a set of new features (sometimes called Androidisms) that were originally added to support Android. Some of the main Androidisms are the low memory killer, wakelocks (integrated as part of wakeup sources support in the mainline Linux kernel), anonymous shared memory (ashmem), alarms, paranoid networking, and Binder. The most important Androidisms for our discussion are Binder and paranoid networking. Binder implements IPC and an associated security mechanism. Paranoid networking restricts access to network sockets to applications that hold specific permissions.

What is Daemon

In the context of Linux, a daemon (pronounced "dee-muhn") refers to a type of background process that runs on a system, typically without any direct interaction with users. The term "daemon" is derived from Greek mythology, where it was used to describe a supernatural being that carries out tasks on behalf of the gods.

Daemons are often started during system boot and continue to run until the system shuts down. They perform various tasks, such as handling network services, managing hardware devices, monitoring system performance, and executing scheduled tasks.

Some key characteristics of daemons in Linux are:

  1. Background operation: Daemons run in the background, detached from any user interface. They don't require a user to be logged in or interact with them directly.
  2. Independence: Daemons are independent of user sessions. They are not tied to a specific user and can continue running even if a user logs out.
  3. Longevity: Daemons are designed to be long-lived processes, running continuously or intermittently as needed.
  4. System services: Many daemons provide essential system services, such as network services (e.g., web servers like Apache or database servers like MySQL), printing services, or logging services.
  5. Configuration: Daemons often have configuration files that allow administrators to customize their behavior. These configuration files specify parameters such as network ports, file paths, and other settings.
  6. Process management: Daemons are typically managed by init systems like Systemd or Upstart, which handle their startup, shutdown, and automatic restart in case of failure.

Examples of common Linux daemons include "sshd" (the Secure Shell daemon responsible for remote login sessions), "httpd" (the Apache HTTP Server daemon), and "cron" (the daemon responsible for executing scheduled tasks).

Native User-space

On top of the kernel is the native user-space layer, consisting of the init binary (the first process started, which starts all other processes), several native daemons, and a few hundred native libraries that are used throughout the system. While the presence of an init binary and daemons is reminiscent of a traditional Linux system, note that both init and the associated startup scripts have been developed from scratch and are quite different from their mainline Linux counterparts.

Dalvik-VM

The bulk of Android is implemented in Java and as such is executed by a Java Virtual Machine (JVM). Android’s current Java VM implementation is called Dalvik and it is the next layer in our stack. Dalvik was designed with mobile devices in mind and cannot run Java bytecode (.class files) directly: its native input format is called Dalvik Executable (DEX) and is packaged in .dex files. In turn, .dex files are packaged either inside system Java libraries (JAR files), or inside Android applications (APK files). Dalvik and Oracle’s JVM have different architectures—register-based in Dalvik versus stack-based in the JVM—and different instruction sets. Let’s look at a simple example to illustrate the differences between the two VMs.