Introduction to Operating Systems: Unit V: Virtual Machines and Mobile OS

Mobile OS: Android

Virtual Machines and Mobile OS - Introduction to Operating Systems

Android is an open source mobile OS developed by the Open Handset Alliance, to led by Google.

Mobile OS: Android

AU: May-22

Android is an open source mobile OS developed by the Open Handset Alliance, to led by Google.

• Android is a software stack for mobile devices that includes an operating system, middleware and key applications.

• It is based on Linux 2.6 kernel.

• Android is an open source operating system, created by Google specifically for use on mobile devices (i.e. cell phones and tablets)

It can be programmed in C/C++ but most app development is done in Java. It supports Bluetooth, Wi-Fi and 3G and 4G networking.

Android Architecture

Fig. 7.6.1 shows Android software stack. Each layer of the stack and the corresponding elements within each layer are tightly integrated and carefully tuned to provide the optimal application development and execution environment for mobile devices. (See Fig. 7.6.1 on next page.)

• Android provides a set of core applications:

1. Email client

2. SMS program

3. Calendar

4. Maps

5. Browser

6. Contacts

7. Etc.

• All applications are written using the Java language.

App framework

• Used for enabling and simplifying the reuse of components

  1. Developers have full access to the same framework APIs used by the core applications.

  2. Users are allowed to replace components.

• App Framework features are as follows:

Libraries

• Libraries include a set of C/C++ libraries used by components of the Android system. It is exposed to developers through the Android application framework

Runtime

• Android run-time system provides core set of class libraries to ensure smooth platform for developers. With these libraries developers can easily import required libraries into their applications without doing any hard coding in applications. 

Dalvik virtual machine

• Dalvik is a purpose built virtual machine designed specifically for android which was developed by Dan Bornstein and his team. Strictly it was developed for mobile devices. While developing Dalvik Virtual Machine Dan Bornstein and his team realize the constraints specific to mobile environment which is not going to change in future at least, like battery life, processing power and many more. So they optimized the dalvik virtual machine. Dalvik virtual machine uses register based architecture. With this architecture dalvik virtual machine has few advantages over java virtual machine such as:

1. Dalvik uses its own 16 bit instruction set than java 8 bit stack instructions, which reduce the dalvik instruction count and raised its interpreter speed.

2. Dalvik use less space, which means an uncompressed .dex file is smaller in size(few bytes) than compressed java archive file(.jar file).

• An open source software stack that includes operating system. Linux operating system kernel that provides low level interface with the hardware, memory management and process control.

Middleware: A run time to execute Android applications including virtual machine and core libraries.

Important blocks in Android":

1. Activity manager: Manages the activity life cycle of applications

2. Content providers: Manage the data sharing between applications

3. Telephony manager: Manages all voice calls. We use telephony manager if we want to access voice calls in our application.

4. Location manager: Location management, using GPS or cell tower

5. Resource manager: Manage the various types of resources we use in our application.

Android SDK features

The Android SDK includes,

1. The Android APIs.

2. The core of the SDK.

3. Development tools.

4. No licensing, distributions, or development fees or release approval processes.

5. GSM, EDGE, and 3G networks for telephony and data transfer.

6. Full multimedia hardware control.

7. APIs for using sensor hardware including accelerometer and the compass.

8. APIs for location based services.

Application framework

 1. Android offers developers the ability to build rich and innovative applications.

 2. Developers have full access to the same framework APIs used by the core applications.

 3. Underlying all applications is a set of services, including Views.

 4. It can be used to build an application, including lists, grids, text boxes, buttons, and even an embeddable web browser.

• Content providers enable applications to access data from other applications (such as Contacts), or to share their own data.

• A resource manager provides access to non-code resources such as localized strings, graphics and layout files.

• A notification manager enables all applications to display custom alerts in the status bar.

• An activity manager manages the lifecycle of applications and provides a common navigation backstack.

Libraries used in Android

• A set of C/C++ libraries used by various components of the Android system.

System C library: Tuned for embedded Linux-based devices.

• Media Libraries: Based on Packet Video's OpenCORE; the libraries support playback and recording of many popular audio and video formats, as well as static image files.

• Surface Manager: Manages access to the display subsystem and seamlessly composites 2D and 3D graphic layers from multiple applications.

• LibWebCore: A modern web browser engine which powers both the Android browser and an embeddable web view.

• SGL/ 3D libraries: SGL is underlying 2D graphics engine.

• SQLite: A powerful and lightweight relational database engine available to all applications.

Android run-time

• Android includes a set of core libraries that most of the functionality available in the core libraries of the Java programming language.

• Every Android app runs in its own process with its own instance of the Dalvik virtual machine. The Dalvik VM executes files in the Dalvik Executable (.dex) format:

Slow Android apps

1. By default on Android, all work is done in a single thread, the "main application" thread. If a component of the work takes a long time, the rest of the work will be "blocked". For example, a long time to access data across the network prevents responding to any GUI events.

2. In the Android OS, if a GUI doesn't respond to an input event in five seconds, then it is considered unresponsive and the OS will try to kill it.

Android thread design

1. Only perform GUI actions on main application thread. Spawn separate threads to perform data-intensive or slow actions. Make these threads asynchronous.

2. Main thread does not have to wait for/check on other threads. Instead, those threads run as they need to and report back to the original thread. Any changes made to the UI should go through the UI thread.

Comparison of Android OS VS iPhone OS Features

Android applications

a.Android applications get distributed in a .apk file. APK stands for "Android board as Package". It is simply a zip file that has a particular file structure. An APKcontains:

  1. The Android Manifest file (an XML file with lots of metadata).

  2. A Resource bundle containing sounds, graphics, etc.

  3. The Dalvik classes that make up user application.

Android Benefits

1. An open and free development platform. Handset makers can use it without royalty and customize to their hearts content.

2. Component-based architecture: Lots of default components can be replaced straightforwardly.

Proponents of Android point to the following benefits:

a. Lots of services location, sql, maps, web, etc.

b. Well managed applications; isolated from each other to protect data and provide

c. Operating system can quit programs as needed to ensure good performance on mobile devices.

d. Portability: To support a new device, a company has to port the virtual machine; Android apps (Dalvik) then execute on the new device with little to no modification.

Zygote

Android uses a concept called the Zygote to enable both sharing of code across VM instances and to provide fast startup time of new VM instances.

• Zygote is a daemon process that provides efficient memory usage and less time overhead when Android runs multiple application. Zygote is the parent of all application processes.

• The Zygote is a VM process that starts at system boot time. When the Zygote process starts, it initializes a Dalvik VM, which preloads and preinitializes core library classes.

• Generally, these core library classes are read-only and are therefore a good candidate for preloading and sharing across processes.

• Once the Zygote has initialized, it will sit and wait for socket requests coming from the runtime process indicating that it should fork new VM instances based on the Zygote VM instance.

Cold starting virtual machines notoriously takes a long time and can be an impediment to isolating each application in its own VM. By spawning new VM processes from the Zygote, the startup time is minimized.

• Additional memory need not be allocated for copies of these classes when a new DVM is forked from the Zygote DVM.


University Question

1. Explain in detail about the Android architecture and its components.

Introduction to Operating Systems: Unit V: Virtual Machines and Mobile OS : Tag: : Virtual Machines and Mobile OS - Introduction to Operating Systems - Mobile OS: Android