OPERATING SYSTEMS Case Study

OPERATING SYSTEMS

Case Study
(Android)

We Will Write a Custom Essay Specifically
For You For Only $13.90/page!


order now

Electronics & Communication Engineering
NSIT

SUBMITTED BY:-
RAJAT RAWAT
118/EC/14
PANKAJ
099/EC/14

Table of Contents
1. Introduction

2. Android Architecture
• Linux Kernel
• Libraries
• Android Runtime
• Application Framework
• Applications

3. Process Management
• Attributes of a Process
• Types of Processes
• Process Scheduling
• Inter Process Communication(IPC)
4. Memory Management
• Allocate App Memory
• Share Memory
• Restricted App Memory
• Garbage Collection

5. References

1.)INTRODUCTION

Android, an operating system for mobiles developed by Google and is designed primarily for touch screen interface mobile devices such as smart-phones and other hand held devices. Its design allows users to manipulate mobile devices intuitively, with phone interactions that mirror common motions, such as pinching, swiping, and tapping. It had been the top most selling OS worldwide since 2011.
Android is based on a modified version of the Linux kernel and other open source software. Since 2008, it has gone through various updates which helped in improving overall performance of operating system. In modern approach it uses monolithic kernel such that different modules like file systems, executable formats etc present in kernel space are loaded and unloaded dynamically at the runtime.. Various versions that android have undergone are Cupcake, Donut, Kitkat etc.

2.)ANDROID – ARCHITECTURE

Android operating system architecture broadly has five component sections as follows:

Linux kernel
It acts as a base of Android architecture present at the bottom of the layers. It is responsible for
• device drivers handling
• power management
• memory management
• device management
• resource access.

Libraries
Above Linux kernel there is a set of native libraries including Web browser engine like WebKit, well known runtime library libc, SQLite database for storage and sharing of application data, FreeType for font support, SSL libraries responsible for Internet security The media framework library provides media codecs for audio and video, OpenGl (Open Graphics Library) and SGL(Scalable Graphics Library) are the graphics libraries for 3D and 2D rendering, respectively. The FreeType Library is used for rendering fonts.

Android Runtime
It is a third section of the architecture, available on the second layer from the bottom. This section provides a key component called Dalvik Virtual Machine which is kind of Java Virtual Machine specially designed and optimized for mobile devices providing fast performance and less memory utilization. It contains set of core libraries that enables developers to write Android Apps using Java.
But since Android 5.0, each app runs in its own process within its own instance of ART virtual machine, which makes process management more crucial. ART also has the facility of efficient garbage collection.

Application Framework
The Android software stack can be divided into five layers: The kernel and low level tools, native libraries, the Android Runtime, the Framework layer and applications. The Application layer provides many higher-level services to applications. Application developers use these services in their applications to improve their overall performance. The Android framework contains the services like Activity Manager, Content Providers, Notifications Manager, Resource Manager, View System. The current version of kernel is Linux 2.6 series kernel. It is modified for special needs in power management.

Applications
All Android application reside at the top layer. These applications are either preinstalled or user manually installs them. Some applications are Books, Contacts, Games, Browser, etc.

3.)PROCESS MANAGEMENT

When a program is being executed in CPU, it is called process. Process management is a way by which different processes share resources and are executed in an optimal way so that properties like synchronisation, mutual exclusion are maintained.
As the android operating system is based on the Linux kernel so it inherits many features of the Linux but at a same time it also deviates from Linux architecture as it has hardware abstraction layer which provides standard interface that associate hardware abilities to higher level frameworks.
When the android operating system first starts, it starts the bootloader which does thing like initialising hardware, initialising kernel etc. for execution. Then init process gets created which is the parent for all other future processes .It performs First it create the low level Linux processes called as daemons ( process that are running in background), these daemons handle low level hardware interfaces. Second it create the zygote process which is also a type of daemon whose mission is to launch the applications, so in a way zygote is the child process of init process and parent of all the other processes. When init process creates zygote, it indirectly creates the first Dalvik VM and calls zygote’s main() method, after that it preloads all the necessary java classes and resources so that each new process can use those resources instead of creating new resources copies each time. Then the zygote start listening to new processes and whenever a new application comes it forks() a process and create a VM instance. Also each application has its own process space and two applications doesn’t share a common process.

Attributes of Process
Process Management in android is same as other operating systems. It also has process control block, process life cycle etc.
A process has states like-
• Active or running: An activity which is running in the foreground is called active process. These are put at top of stack. These activities can be stopped only in extreme situations.
• Stopped: The activity is completely stopped when either the execution has been completed or the OS require memory to execute some other process.
• Paused: If any interrupt occurs then activity goes in the pause state. When interrupt ends, the activity is resumed from where it was stopped.
• Termination: This state occurs when activity has completed or it is destroyed so that all the resources used by it are restored and are given to some other activity which is active at that time.

Types of processes
• Foreground process: This is given the top priority. This is the process which is running when user is interacting with the screen. These are few in number and are only killed when the memory is very low so that these need to be killed to make the user interface responsive.
• Service process: A service process is holding a service started with the startService () method .These impact the user though not visible to user like uploading and downloading.
• Background process: Background processes are not visible to the user. At any given time, many background processes are currently running. They have no impact on the experience of using the phone. Background processes can be taken as “paused” apps.
• Visible process: A process is said to be visible when it is running in foreground but the user is not currently interacting with the process.
• Cached process: These are the process that are currently not needed, so the system is free to kill it as desired when memory is needed elsewhere.

Process Scheduling
Android uses same standard scheduling algorithms such as FCFS, round robin etc.

Inter Process Communication
Android uses various inter process communication (IPC) methods such as
• Intents- These are messages which are send and receive. It is universal mechanism of passing data between processes. These are an abstract description of an operation to be performed.
• Bundles- These are entities through which data to be passed is send. It converts an object into stream of byte at fast rate.
• Binders- These are simply entities which allows activities and services obtain a reference to another services. Thus it not simply send messages to services but directly invoke methods on them. In simple terms the binder are used to communicate between a server process and an application process and invoke methods of other process.

4.)MEMORY MANAGEMENT
The Android Runtime (ART) and Dalvik virtual machine uses paging and memory-mapping to manage memory. So, when an app modifies any memory by allocating new objects or by touching memory-mapped pages, it remains in RAM and can’t be paged out. To release memory from an app object references that the app holds are released from it which makes the memory available to the garbage collector.

Allocate and Reclaim App memory
The Dalvik heap is constrained to a single virtual memory range for each app process. This defines the logical heap size which can grow with time but to a limit defined by App. When Android inspects apps heap, it computes Proportional Set Size (PSS) value. PSS accounts for both dirty and clean pages that are shared with other processes. But this amount is proportional to how many apps share that RAM. Total value of PSS is considered as physical memory footprint.
The Dalvik heap does not compact the logical size of the heap. Heap is not defragmented to close up space. When heap has free space then android shrinks heaps logical size and unused pages are returned to Kernel.

Share Memory
Android shares RAM pages across processes, to fit everything it needs in RAM. Some other possible ways are:-
• Each app process is forked from an existing process called Zygote. To start a new app process, the system forks the Zygote process then loads and runs the app’s code in the new process. This approach allows most of the RAM pages allocated for framework code and resources to be shared across all app processes.
• Most static data is mapped into a process.
• In many places, Android shares the same dynamic RAM across processes using explicitly allocated shared memory regions. For example, window surfaces use shared memory between the app and screen compositor, and cursor buffers use shared memory between the content provider and client.

Restrict App Memory
A size limit on heap is put by Android so that multi tasking works with maximum efficiency. Heap size depends on available RAM to device. If app has reached the heap capacity and tries to allocate more memory, it receives an Out Of Memory Error.
If we want to know exactly how much heap space is available on the current device, it is done by calling getMemoryClass(). This returns an integer indicating the number of megabytes available for your app’s heap.
Garbage Collection
A managed memory environment, like the ART or Dalvik virtual machine, keeps track of each memory allocation. When a part of memory is not used by the program, it frees it and puts it back to the heap. The mechanism to reclaim unused memory within a managed memory environment is known as garbage collection. Garbage collection has two goals:
• Find data objects that can’t be accessed in the future.
• Reclaim the resources used by those objects.
Each heap generation has its limit of memory that the objects present there can occupy. System executes garbage collection event when generation starts to fill up. But garbage collection can affect apps performance. We can’t control this event from within our code. When a specific criteria is met system stops process and starts executing garbage collection event.

5.)REFERENCES

1. https://www.androidauthority.com/what-is-virtual-memory-gary-explains-747960/

2. https://acadgild.com/blog/android-devices-memory-management/

3. https://mobworld.wordpress.com/2010/07/05/memory-management-in-android/

4. https://android.stackexchange.com/questions/62452/android-virtual-memory-support

5. https://www.howtogeek.com/161225/htg-explains-how-android-manages-processes/

6. https://www.it.iitb.ac.in/frg/wiki/images/2/2b/113050076_Rajesh_Prodduturi_week8_report_7_2012-08-25.pdf

7. https://developer.android.com/guide/components/processes-and-threads.html

8. Wikipedia