In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
What is the evolution of Android system architecture? I believe many inexperienced people are at a loss about it. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
Android is an open source operating system based on Linux and JAVA. Android is divided into application layer, application framework layer, system runtime layer and Linux kernel layer. Today, let's review the evolution of Android system architecture.
I. android and linux kernels
Android is an operating system based on the Linux kernel, but it is still very different from Linux. For example, Android adds its own unique drivers to the Linux kernel. Why did Android choose Linux?
1. Powerful memory management and process management solutions
2. Security mode based on permissions
3. Support shared libraries
4. Certified driver model
5. Linux itself is an open source project
The main changes made by Android to the linux system are
(1) it does not have glibc support.
Since Android was originally used on some portable mobile devices, perhaps because of efficiency and other considerations, Android did not use glibc as the C library, but Google developed a set of Bionic Libc to replace glibc.
(2) it does not include a set of standard Linux procedures.
Android did not completely copy the kernel of the Liunx system, in addition to correcting part of the Bug of Liunx, but also added a lot of content, such as: it is based on the ARM framework of the increased Gold-Fish platform, and yaffs2 FLASH file system (if you learn embedded, you will know that yaffs2 FLASH file system has been used in many embedded devices based on linux, the technology has been very mature) and so on. It does not have a native X service-based window system. What is the local window system? The local windowing system refers to the X windowing system on GNU/Linux or the Quartz of Mac OX X. Different operating systems may have different window systems, and Android does not use (and does not need to use) Linux's X window system.
(3) Android proprietary drivers
In addition to the above differences, the most important thing is that in order to highlight the android features and support android devices, Android has also enhanced the Linux device driver, as shown below.
A. Android Binder is based on a driver of the OpenBinder framework and is used to provide the InterProcessCommunication,IPC function of the Android platform. The source code is located in drivers/staging/android/binder.c.
B. Android Power Management (PM) A lightweight Linux power management driver based on the standard Android power management system, which makes a lot of optimizations for embedded devices. The source code is located at:
Kernel/power/earlysuspend.c
Kernel/power/consoleearlysuspend.c
Kernel/power/fbearlysuspend.c
Kernel/power/wakelock.c
Kernel/power/userwakelock.c
C. Low memory Manager (Low Memory Killer) is more flexible than Linux's standard OOM (Out Of Memory) mechanism, which can kill processes as needed to free up needed memory. The source code is located in drivers/staging/ android/lowmemorykiller.c.
Anonymous shared memory (Ashmem) provides large chunks of shared memory between processes, while providing a mechanism for the kernel to reclaim and manage this memory. The source code is located in mm/ashmem.c.
E, Android PMEM (Physical) PMEM is used to provide continuous physical memory areas to user space, DSP and some devices can only work on continuous physical memory. The source code is located in drivers/misc/pmem.c.
F, Android Logger is a lightweight log device, which is used to grab various logs of Android system. The source code is located in drivers/staging/android/logger.c.
G and Android Alarm provide a timer for waking the device from sleep, and it also provides a clock benchmark that runs even when the device is sleeping. The source code is located in drivers/rtc/alarm.c.
H, USB Gadget driver is a device driver based on the standard Linux USB gadget driver framework, and the USB driver of Android is based on the gaeget framework. The source code is located in drivers/usb/gadget/.
I, Android Ram Console to provide debugging functionality, Android allows debug log information to be written to a device called RAM Console, which is a RAM-based Buffer. The source code is located at drivers/staging/android / ram_console.c.
J and Android timed device provide the function of timing control of the device, and currently support vibrator and LED devices. The source code is located at drivers/staging/android / timed_output.c (timed_gpio.c).
K, Yaffs2 file system Android uses Yaffs2 as the MTD nand flash file system, and the source code is located in the fs/yaffs2/ directory. Yaffs2 is a fast and stable cross-platform embedded device file system applied to NAND and NOR Flash. Compared with other Flash file systems, Yaffs2 can use less memory to save its running state, so it takes up less memory. Yaffs2 garbage collection is very simple and fast, so it can show better performance. The performance of Yaffs2 is particularly outstanding on high-capacity NAND Flash, which is very suitable for high-capacity Flash storage.
The latest Android system is divided into five layers and six regions (domains).
1. Linux kernel layer (Linux Kernel): the Android system is based on the Linux2.6 kernel. This layer provides underlying drivers for various hardware of Android devices, such as display driver, audio driver, camera driver, Bluetooth driver, Wi-Fi driver, power management, etc.
2. Hardware abstraction layer (android hardware abstraction layer): the way Android drives hardware is different from Linux. The driver of traditional Linux lives completely in kernel space. Android adds a hardware abstraction layer (HAL, Hardware Abstraction Layer) outside the kernel to put part of the driver functions into the HAL layer. Why would Android bother to add a HAL? To protect the source code. The GPL protocol is adopted in the Linux kernel, so if hardware manufacturers want to support Linux systems, they must disclose the source code of the hardware drivers in accordance with the GPL protocol. However, these source codes contain a lot of hardware design information, involving the core interests of hardware manufacturers. With the addition of the HAL layer, hardware manufacturers do not need to open up all the driver code.
3. System runtime layer (libraries): this layer provides the main feature support for Android system through some so libraries. For example, SQLite library provides database support, OpenGL ES library provides 3D drawing support, Webkit library provides browser kernel support, and so on.
4. Application Framework layer (application framework): this layer mainly provides a variety of core applications included with API,Android that may be used when building applications, and developers can also use these API to build their own applications; Application layer (applications): this layer is mainly used for the installation of mobile applications, such as the system comes with contacts, SMS and other programs, or third-party applications.
The above is five layers and five zones, and another area is the Android runtime library (Android Runtime) that exists in the libraries layer, which mainly provides some core libraries that allow developers to write Android applications in the Java language. In addition, the Android runtime library also includes a Dalvik virtual machine, which enables each Android application to run in a separate process and has its own Dalvik virtual machine instance. Compared with the Java virtual machine, Dalvik is specially customized for mobile devices, and it optimizes the limited memory and CPU performance of mobile phones. Each Android application runs on its own process and enjoys a proprietary instance assigned to it by the Dalvik virtual machine. Dalvik has been rewritten to enable multiple virtual machines to run efficiently on the same device. The Dalvik virtual machine executes executable files (.dex) in Dalvik format-the format is optimized to minimize memory usability.
III. Dalvik virtual machine and code compilation
Android apps are written by Java, while Linux libraries, including HAL, are written by CUnix Candle +, a gap bridged by the Dalvik virtual machine. When an application is running, the process space will contain a Dalvik virtual machine. The Java program is compiled into a bytecode file and runs in the Dalvik virtual machine. According to the requirements in the Java code, Dalvik invokes the functions written by the underlying CumberCutter + through JNI (Java Native Interface). JNI is the interface that invokes the Cmax Candle + module from Java. Due to the standardization of the upper interface, the bytecode can run across platforms without hindrance.
Inside the Dalvik virtual machine is a "virtual" process space with its own stack and heap to manage the flow of the code. If this runs out of "virtual" process space, Dalvik's built-in garbage collection (garbage collection) mechanism automatically empties objects on the heap that are no longer in use. Automatic garbage collection simplifies the work of programmers, but at a slower speed. Manual memory management is efficient, but requires more programming and is prone to mistakes.
Four file types of Android Java,class,dex,apk
Class file-the object file compiled by Java can not be run directly like J2seMagna java compiled into class, and the class file on the android platform cannot be run directly on android. Because Google uses its own Dalvik to run applications, the class here certainly cannot be run in the java environment of AndroidDalvik. The class file of android is actually an intermediate object file in the process of compilation and needs to be linked into a dex file before it can be run on dalvik.
Dex file-the executable file Android virtual machine Dalvik on the Android platform supports bytecode file format Google, which is defined on the newly released Android platform using its own Dalvik virtual machine, which executes a different type of bytecode instead of Java bytecode: Java bytecode. After compiling Java code, you can convert Java bytecode to Dex bytecode through tools on the Android platform. Although Google says Dalvik is customized for mobile devices, many in the industry think it is to avoid applying for Javalicense from sun. This DalvikVM is optimized for mobile app / CPU and can run many VM at the same time without consuming too much Resource.
Apk files-the installation file on Android Apk is the extension of the Android installation package, and an Android installation package contains all the files related to an Android application. Apk files compress AndroidManifest.xml files, application code (.dex files), resource files, and other files into a package. Only one .apk file can be entered into a project.
After reading the above, have you mastered the evolution of Android system architecture? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.