Android os

700 views

Published on

This Presentation is targeting for deep knowledge of android OS that cover below topics:
History
Architecture
Dalvik Virtual Machine(DVM)
Process Management
Memory Management
Application and Service Lifecycle

Published in: Education, Technology
0 Comments
6 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
700
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
0
Comments
0
Likes
6
Embeds 0
No embeds

No notes for slide
  • Open Handset Alliance(OHA)
  • The Open Handset Alliance (OHA) is a consortium of 84[1] firms to develop open standards for mobile devices. Member firms include Google, HTC, Sony, Dell, Intel, Motorola, Qualcomm, Texas Instruments, Samsung Electronics, LG Electronics, T-Mobile, Sprint Corporation, Nvidia and Wind River Systems.The OHA was established on 6 November 2007, led by Google with 34 members including mobile handset makers, application developers, some mobile carriers and chip makers.Android, the flagship software of the alliance, is based on an open source license and has competed against mobile platformsfrom Apple, Microsoft, Nokia (Symbian), HP (formerly Palm), Samsung Electronics / Intel (Tizen, bada), and Blackberry.Members of OHA are not allowed to produce phones that run incompatible versions of Android.
  • Includes a set of core libraries that provides most of the functionality-JAVAEvery Android application runs in its own processDalvik VM executes files in the (.dex) formatDevice can run multiple VMs efficiently.==================================================All applications written in Java and converted to the Dalvik executable .dex.Every android app runs its own process, with its own instance of the Dalvik virtual machine.Not a traditional JVM, but a custom VM designed to run multiple instances efficiently on a single device.VM uses Linux kernel to handle low-level functionality including security, threading, process and memory managemet.
  • Activity Manager :Manages the lifecycle of applicationsContent provider : Enable applications access data from other applicationsResource Manager :Providing access to non-code resourcesWindow ManagerNotification managerSQLite Databases: relational database library for storing and managing complex dataFiles: you can create, write, and read files from the local storage or external media (SD Cards)FileOutputStream, FileInputStream, and Resources classes.=======================================================Set of core applications including an email client, SMS program, calendar, maps, browser, contacts.All applications are written using the Java programming language.Built in and user apps.Can replace built in apps.
  • Activity Manager :Manages the lifecycle of applicationsContent provider : Enable applications access data from other applicationsResource Manager :Providing access to non-code resourcesWindow ManagerNotification managerSQLite Databases: relational database library for storing and managing complex dataFiles: you can create, write, and read files from the local storage or external media (SD Cards)FileOutputStream, FileInputStream, and Resources classes.=======================================================Set of core applications including an email client, SMS program, calendar, maps, browser, contacts.All applications are written using the Java programming language.Built in and user apps.Can replace built in apps.
  • Activity Manager :Manages the lifecycle of applicationsContent provider : Enable applications access data from other applicationsResource Manager :Providing access to non-code resourcesWindow ManagerNotification managerSQLite Databases: relational database library for storing and managing complex dataFiles: you can create, write, and read files from the local storage or external media (SD Cards)FileOutputStream, FileInputStream, and Resources classes.=======================================================Set of core applications including an email client, SMS program, calendar, maps, browser, contacts.All applications are written using the Java programming language.Built in and user apps.Can replace built in apps.
  • A stack based virtual machine implements the general features described as needed by a virtual machine in the points above, but the memory structure where the operands are stored is a stack data structure. Operations are carried out by popping data from the stack, processing them and pushing in back the results in LIFO (Last in First Out) fashion. In a stack based virtual machine, the operation of adding two numbers would usually be carried out in the following manner (where 20, 7, and ‘result’ are the operands):Because of the PUSH and POP operations, four lines of instructions is needed to carry out an addition operation.An advantage of the stack based model is that the operands are addressed implicitly by the stack pointer (SP in above image). This means that the Virtual machine does not need to know the operand addresses explicitly, as calling the stack pointer will give (Pop) the next operand. In stack based VM’s, all the arithmetic and logic operations are carried out via Pushing and Popping the operands and results in the stack.
  • As I mentioned earlier, there is no POP or PUSH operations, so the instruction for adding is just one line.But unlike the stack, we need to explicitly mention the addresses of the operands as R1, R2, and R3.The advantage here is that the overhead of pushing to and popping from a stack is non-existent, and instructions in a register based VM execute faster within the instruction dispatch loop.Another advantage of the register based model is that it allows for some optimizations that cannot be done in the stack based approach. One such instance is when there are common sub expressions in the code, the register model can calculate it once and store the result in a register for future use when the sub expression comes up again, which reduces the cost of recalculating the expression.The problem with a register based model is that the average register instruction is larger than an average stack instruction, as we need to specify the operand addresses explicitly.Whereas the instructions for a stack machine is short due to the stack pointer, the respective register machine instructions need to contain operand locations, and results in larger register code compared to stack code.
  • Every Android application runs in its own process, with its own instance of the Dalvik virtual machine. Dalvik has been written so that a device can run multiple VMs efficiently. The Dalvik VM executes files in the Dalvik Executable (.dex) format which is optimised for minimal memory footprint. The VM is register-based, and runs classes compiled by a Java language compiler that have been transformed into the .dex format by the included “dx” tool.Android programs are compiled into .dex (Dalvik Executable) files, which are in turn zipped into a single .apk file on the device. .dex files can be created by automatically translating compiled applications written in the Java programming language.
  • Page based Memory management:·         Extracts the page number concern.·         Extract the offset to be used.·         Check that the page number is within the address space of the process.·         Add offset to resulting physical page number.·         Access the memory location.============================================Physical addressing means that your program actually knows the real layout of RAM. When you access a variable at address 0x8746b3, that's where it's really stored in the physical RAM chips.With virtual addressing, all application memory accesses go to a page table, which then maps from the virtual to the physical address. So every application has its own "private" address space, and no program can read or write to another program's memory. This is called segmentation.Virtual addressing has many benefits. It protects programs from crashing each other through poor pointer manipulation, etc. Because each program has its own distinct virtual memory set, no program can read another's data - this is both a safety and a security plus. Virtual memory also enables paging, where a program's physical RAM may be stored on a disk (or, now, slower flash) when not in use, then called back when an application attempts to access the page. Also, since only one program may be resident at a particular physical page, in a physical paging system, either a) all programs must be compiled to load at different memory addresses or b) every program must use Position-Independent Code, or c) some sets of programs cannot run simultaneously.The physical-virtual mapping may be done in software (with hardware support for memory traps) or in pure hardware. Sometimes even the page tables themselves are on a special set of hardware memory. I don't know off the top of my head which embedded system does what, but every desktop has a hardware TLB (Translation Lookaside Buffer, basically a cache for the virtual-physical mappings) and some now have advanced Memory Mapping Units that help with virtual machines and the like.The only downsides of virtual memory are added complexity in the hardware implementation and slower performance.
  • Android os

    1. 1. 1. INTRODUCTION 2. ARCHITECTURE 3. Dalvik Virtual Machine(DVM) 4. Process Management 5. Memory Management 6. Application and Service Lifecycle
    2. 2.  Android is Mobile(Device) Based OS.  Which is based on Linux 2.6 kernel.  Android Inc.(founded in 2003 and is based in Palo Alto, California) which operated as subsidiary of Google and later purchased by Google in 2005.  OHA Est. 5th Nov 2007, led by Google, open Source.  Open source under the Apache 2 license.  Android was publicly announced in 2007 and first phone was sold on October 2008.  HTC was First to deliver ANDROID Mobile Device.
    3. 3. • Linux kernel • Libraries • Android run time – core libraries – Dalvik virtual machine • Application layer • Application protocol
    4. 4.  Acts as an abstraction layer between the hardware and the rest of the software stack.  Relies on Linux version 2.6 for core system services such as security, memory management, process management, network stack, and driver model.  Works as a HAL (Hardware Abstraction Layer or rather Hardware Annotation Library)
    5. 5. System C library - implementation of the C library (libc). Media Libraries - based on PacketVideo's Open CORE. Surface Manager - composites 2D and 3D graphic layers LibWebCore - a modern embeddable web view. SGL - the underlying 2D graphics engine. 3D libraries - based on OpenGL ES 1.0 APIs; the libraries use hardware 3D acceleration.  FreeType - bitmap and vector font rendering  SQLite - a powerful and lightweight relational database engine .      
    6. 6.  Includes a set of core libraries of JAVA that provides most of the functionality  Runs in its own process, with its own instance of the Dalvik Virtual Machine  The Dalvik VM executes files in the Dvbalvik Executable (.dex)  Compact and efficient than class files  Limited memory and battery power
    7. 7.  Access location information, run background services, set alarms, add notifications to the status bar, and much, much more.  Build an application, including lists, grids, text boxes, buttons, and even an embeddable web browser  Providing access to non-code resources such as localized strings, graphics, and layout files.  Activity manager manages application life cycle.  Content provider Enable applications access data from other applications.
    8. 8.  resource manager which gives us access to non court resources such as localized strings or various others, we can layout so many resources, we can have in the form of PNG, BMP as well as XML so resource manager helps us to get access to those non code resources.  Notification manager which helps us to display custom alerts on status bar.  location managers it handles information about the location.  telephony manager which handles information about telephony.
    9. 9. Stack Based Virtual Machine(ex.JVM) POP 20 POP 7 ADD 20, 7, result PUSH result
    10. 10. Register Based Virtual Machine(ex.DVM) Add R3,R1,R2
    11. 11.  A special Java Virtual Machine(VM) designed to run with limited system resource.  It is basically a virtual machine for embedded devices, which like any other virtual machine, is a byte code interpreter.  it means it is low on memory, comparatively slower and runs on battery power.  Google is modify DVM according to the Android OS is named as Dalvik Turbo virtual machine.  Java class file are converted into “.dex” Files that Dalvik executes  Java byte code is converted into Dalvik bytecode during this process
    12. 12.  For each application android creates a new process with single thread of execution(i.e. main thread)  By default all the components run in same thread(main thread) If not developer explicitly creates a new thread.  In low memory situations a process is decide to kill based upon the number of inactive components of that process.  A process which have more number of inactive components should be killed first.
    13. 13.  A process is treated as foreground if any of components of process holds following states.  An activity which is interacting with user. When an activity calls methods like onstart(), onresume().  When a service is interacting with foreground activity.  When a service is started using startForeground().  when a service is executing any of the methods like onCreate(),onStart(), onDestroy().
    14. 14.  Visible, but inactive processes are those hosting “visible” Activities. As the name suggests, visible Activities are visible, but they aren’t in the foreground or responding to user events.  This happens when an Activity is only partially obscured (by a non-full-screen or transparent Activity).  There are generally very few visible processes, and they’ll only be killed in extreme circumstances to allow active processes to continue.  An activity which is not interacting with user. But it is still visible to user, when an activity running method like onPause().
    15. 15.  Processes hosting Services that have been started. Services support ongoing processing that should continue without a visible interface.  Because Services don’t interact directly with the user, they receive a slightly lower priority than visible Activities.  They are still considered to be foreground processes and won’t be killed unless resources are needed for active or visible processes.  When a service is started using startService().  Eg: playing music in background, downloading file from internet.
    16. 16.  Processes hosting Activities that aren’t visible and that don’t have any Services that have been started are considered background processes.  There will generally be a large number of background processes that Android will kill using a last-seen-firstkilled pattern to obtain resources for foreground processes.  When an activity running method like onStop(). i.e currently user is not interacting with that activity.  Whenever a process decided to kill, it stores the state of activity. So whenever next time user wants that activity, we can restore the previous state of activity.
    17. 17.  To improve overall system performance, Android often retains applications in memory after they have reached the end of their lifetimes.  Android maintains this cache to improve the start-up time of applications when they’re re-launched.  These processes are routinely killed as required.  When a process does not have any active component.  Caching of empty process inside memory, reduces relaunching of application once again if user wants that application in future.
    18. 18.  Page-based memory management  Virtual address to physical address mapping  No virtual memory
    19. 19.  Android’s process and memory management is a little unusual.  Like Java and .NET, Android uses its own run time and virtual machine to manage application memory.  Unlike either of these frameworks, the Android run time also manages the process lifetimes.  Android ensures application responsiveness by stopping and killing processes as necessary to free resources for higher-priority applications.  Each Android application runs in a separate process within its own Dalvik instance, relinquishing all responsibility for memory and process management to the Android run time, which stops and kills processes as necessary to manage resources.  Dalvik Virtual Machine Dalvik is a register-based virtual machine that’s been optimized to ensure that a device can run multiple instances efficiently. It relies on the Linux kernel for threading and low-level memory management.
    20. 20.  The order in which processes are killed to reclaim resources is determined by the priority of the hosted applications. An application’s priority is equal to its highestpriority component.  Where two applications have the same priority, the process that has been at a lower priority longest will be killed first.  Process priority is also affected by interprocess dependencies  if an application has a dependency on a Service or Content Provider supplied by a second application, the secondary application will have at least as high a priority as the application it supports.  All Android applications will remain running and in memory until the system needs its resources for other applications.
    21. 21.  Application run in their own processes (VM, PID)  Processes are started and stopped as needed to run an application's components  Processes may be killed to reclaim resources
    22. 22. Thank You

    ×