Saturday, 20 December 2014

Layers in Architecture



In this post, we will have a closer look at each layer of the Android Architecture. In case if you have missed reading my previous post, then I would suggest you to read it once.
       The Android architecture consist of four layers, the first and base layer is Linux Kernel version 3.4 or newer (as of January 2014) with slight enhancements. Android has used various kernels since its first 2.6.25. Android's Linux kernel has further more changes done by Google outside the typical Linux Kernel development cycle.
Android's Linux Kernel

Android's Linux Kernel
  As you can see from the figure, it contains all your device drivers which directly talks to your hardware such as Display Driver, Camera Driver, Wifi Drver, Audio Driver, Binder (IPC) Driver etc.

 But here are some enhancements made by Google typically to make Linux Kernel compatible with Android devices.
1) Binder 
  Binder is an Android-specific interprocess communication mechanism, and remote method invocation system. So what it means, one Android process can call routine in another android process.

2) Ashmem 
 Stands for Android Shared Memory. The ashmem subsystem is a new shared memory allocator, but with different behavior and sporting a simpler file-based API." Apparently, supports better for low memory devices.
3) Logger
  It provides system logging facility. This is the kernel support for the 'logcat' command.
4) WakeLocks
   These are used for power management. It tries to holds machine awake on a per-event basis until wakelock is released.
5) No glibc support (bionic libc instead). Does not include the full set of standard Linux utilities.

 Native Libraries and Runtime:

Then we have all Native libraries and even Android Runtime environment in the next layer of architecture.
    In this layer, we have all supported libraries written mostly in C. Here are some key points on this layer:

 Bionic LIBC
 Small size and fast code paths
 Built-in support for Android-specific services
 Not compatible with GNU libc, all native code must be compiled against Bionic

Other important libraries such as:
 Sqlite used for storing data (similar to SQL), Media libs, WebKit used by web browsers etc.

Native Servers such as  Surface flinger, Audio Manager which we will be talking about within next few post.
   Then we have Android Runtime. which consist of Dalvik Virtual Machine. Here are some key point on Dalvik VM:
1) Named after Dalvik, a village in Iceland.
2) Uses JIT Compiler (Just In Time Compiler)

3) Runs optimized file format (.dex) and Dalvik bytecode, Java .class / .jar files converted to .dex at build time

4) Supports multiple virtual machine processes per device.

5) Uses runtime memory efficiently.
Note: Prior to Android 5.0 Lollipop, it was Dalvik VM but now with the release of newest Android version i.e Lollipop we have ART Runtime envirionment which uses AOT Compiler (Ahead of Time)
 

No comments:

Post a Comment