Chinaunix首页 | 论坛 | 博客
  • 博客访问: 333071
  • 博文数量: 102
  • 博客积分: 2510
  • 博客等级: 少校
  • 技术积分: 1146
  • 用 户 组: 普通用户
  • 注册时间: 2010-01-21 22:33
文章分类

全部博文(102)

文章存档

2011年(8)

2010年(94)

我的朋友

分类: 嵌入式

2010-01-23 20:46:07

?ui=2&view=att&th=124b8b29ff269b9c&attid=0.1&disp=attd&realattid=ii_124b8b29ff269b9c&zw



首先看系统架构框架图如下:

android的系统架构和其操作系统一样,采用了分层的架构。从架构图看,android分为四个层,从高层到低层分别是应用程序层、应用程序框架层、系统运行库层(包含系统库和Android运行库)和linux核心层。

Applications
Application Framework
Libraries
Android Runtime
Linux Kernel

Android本身是一套软件堆叠(Software Stack),主要分为三层:操作系统、中间件、应用程序。
Android的中间件可以再细分出两层,底层是函数库(Library)和虚拟机(Virtual Machine; VM),上层为应用程序框架(Application Framework)。上面架构图中蓝色部分为Java语言开发,绿色部分为C/C++开发,红色的Kernel层为C开发,黄色部分为Dalvik VM部分。

以下分别介绍每一层的作用

应用程序层(Applications)

Android会同一系列核心应用程序包一起发布,该应用程序包包括email客户端,SMS短消息程序,日历,地图,浏览器,联系人管理程序等。所有的应用程序都是使用JAVA语言编写的。

应用程序框架层(Application Framework)

开发人员也可以完全访问核心应用程序所使用的API框架。该应用程序的架构设计简化了组件的重用;任何一个应用程序都可以发布它的功能块并且任何其它的应用程序都可以使用其所发布的功能块(不过得遵循框架的安全性限制)。同样,该应用程序重用机制也使用户可以方便的替换程序组件。
隐藏在每个应用后面的是一系列的服务和系统, 其中包括;
Views System:丰富而又可扩展的视图(Views),可以用来构建应用程序, 它包括列表(lists),网格(grids),文本框(text boxes),按钮(buttons), 甚至可嵌入的web浏览器。
Content Providers(内容提供器):使得应用程序可以访问另一个应用程序的数据(如联系人数据库), 或者共享它们自己的数据。
Resource Manager(资源管理器):提供非代码资源的访问,如本地字符串,图形,和布局文件( layout files )
Notification Manager(通知管理器):使得应用程序可以在状态栏中显示自定义的提示信息。。通知列设定在手机的顶部,像短信(short Message),Voice mail都会在此进行提示。
Activity Manager(Activity管理):用来管理应用程序生命周期并提供常用的导航回退功能。

函数库层(Libraries)

Android 包含一些C/C++库,这些库能被Android系统中不同的组件使用。它们通过 Android 应用程序框架为开发者提供服务。以下是一些核心库:
System C library – 一个从 BSD 继承来的标准 C 系统函数库( libc ), 它是专门为基于 embedded linux 的设备定制的。
Media Libraries – 基于 PacketVideo OpenCORE;该库支持多种常用的音频、视频格式回放和录制,同时支持静态图像文件。编码格式包括MPEG4, H.264, MP3, AAC, AMR, JPG, PNG 。
Surface Manager [...]

2.

Android的特色

Application framework: 提供可重用可替换的组件

Dalvik virtual machine: 为移动设备优化过的Java虚拟机

Integrated browser: 基于WebKit引擎的开放源码的浏览器

Optimized graphics: 优化过的图形函数库,包含了SGL的2D图形函数库和基于OpenGL ES 1.0规范的3D图形函数库(可选硬件加速)

SQLite: 内置SQLite数据库

Media support: 支持通用的音频,视频,和图形格式 (MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, GIF)

GSM通话(由设备硬件决定支持与否)

Bluetooth, EDGE, 3G, and WiFi (由设备硬件决定支持与否)

摄像头, GPS, 电子罗盘, 加速度感应器(由设备硬件决定支持与否)

Rich development environment: 包含了设备模拟器, 除错工具,内存和性能分析工具(我们没有用过哦), 使Eclipse支持Android开发的插件(ADT)


Android,让我来"扒"你的皮吧~!!!!

先从Dalvik vm开始~

解释器汇编代码运行原理

这一篇看不懂.

file:///home/hamody/borqs/devices/JIL_mavell_20056_b314/dalvik/docs/embedded-vm-control.html#checkjni   这个还好一些
ie:

Like other desktop VMs, when the Dalvik VM receives a SIGQUIT (Ctrl-\ or kill -3), it dumps stack traces for all threads. By default this goes to the Android log, but it can also be written to a file.

The dalvik.vm.stack-trace-file property allows you to specify the name of the file where the thread stack traces will be written. The file will be created (world writable) if it doesn't exist, and the new information will be appended to the end of the file. The filename is passed into the VM via the -Xstacktracefile argument.

For example:

adb shell setprop dalvik.vm.stack-trace-file /tmp/stack-traces.txt

If the property is not defined, the VM will write the stack traces to the Android log when the signal arrives.


Dalvik Libraries

The Dalvik Libraries, also known as the Android core libraries, implement general purpose APIs used by code written in the Java programming language. While the libraries themselves don't depend on Android, they do form the foundation of the Android framework. Android applications use the Dalvik libraries both directly and indirectly for data structures, networking, concurrency, I/O, and more.

The Dalvik libraries break down into two categories:

与dalvikvm and app 相关的库...介于c and app之间,提供dalvik vm and app(java) run environment.

Dalvik Debugger Support(看不懂)

一些工具使用,之前见tigran使用过.

Dalvik Optimization and Verification Withdexopt


The Dalvik virtual machine was designed specifically for the Android mobile platform. The target systems have little RAM, store data on slow internal flash memory, and generally have the performance characteristics of decade-old desktop systems. They also run Linux, which provides virtual memory, processes and threads, and UID-based security mechanisms.

The features and limitations caused us to focus on certain goals:

  • Class data, notably bytecode, must be shared between multiple processes to minimize total system memory usage.
  • The overhead in launching a new app must be minimized to keep the device responsive.
  • Storing class data in individual files results in a lot of redundancy, especially with respect to strings. To conserve disk space we need to factor this out.
  • Parsing class data fields adds unnecessary overhead during class loading. Accessing data values (e.g. integers and strings) directly as C types is better.
  • Bytecode verification is necessary, but slow, so we want to verify as much as possible outside app execution.
  • Bytecode optimization (quickened instructions, method pruning) is important for speed and battery life.
  • For security reasons, processes may not edit shared code.

Dalvik VM
Debug Monitor

It's extremely useful to be able to monitor the live state of the VM. For Android, we need to monitor multiple VMs running on a device connected through USB or a wireless network connection. This document describes a debug monitor server that interacts with multiple VMs, and an API that VMs and applications can use to provide information to the monitor.

Some things we can monitor with the Dalvik Debug Monitor ("DDM"):

  • Thread states. Track thread creation/exit, busy/idle status.
  • Overall heap status, useful for a heap bitmap display or fragmentation analysis.



Dalvik wiki said:

Being optimized for low memory requirements, Dalvik has some specific characteristics that differentiate it from other standard VMs:

  • The VM was slimmed down to use less space. (经过瘦身用更少的space)
  • Dalvik has no    -->更高效的执行? 
  • (In , just-in-time compilation (JIT), also known as dynamic translation, is a technique for improving the runtime performance of a . JIT builds upon two earlier ideas in run-time environments: bytecode compilation and . It converts code at  prior to executing it natively, for example  into native machine code. The performance improvement over interpreters originates from caching the results of translating blocks of code, and not simply reevaluating each line or operand each time it is met (see ). It also has advantages over statically compiling the code at development time, as it can recompile the code if this is found to be advantageous, and may be able to enforce security guarantees. Thus JIT can combine some of the advantages of interpretation and static () compilation.)
  • The  has been modified to use only  indexes to simplify the .(
  • The constant pool

    The constant pool table is where most of the literal constant values are stored. This includes values such as numbers of all sorts, strings, identifier names, references to classes and methods, and type descriptors. All indexes, or references, to specific constants in the constant pool table are given by 16-bit (type u2) numbers, where index value 1 refers to the first constant in the table (index value 0 is invalid).)
  • It uses its own bytecode, not .(Java bytecode is the form of instructions that the  executes. Each  is one byte in length, although some require parameters, resulting in some multi-byte instructions. )

Moreover, Dalvik has been designed so that a device can run multiple instances of the VM efficiently.

阅读(1453) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~