iOS is based on Unix kernel, Android is based on Linux kernel, iOS and Android as two excellent mobile operating systems, they have similarities and differences.
system architecture for iOS
Divided into four levels:
Core operating system layers (core OS layer)
Core Services Tier (core service layer)
Media layer
Touch layers (Cocoa touch layer)
As shown below:
iOS System Architecture parsing:
1, Core OS is located at the bottom of the iOS system Architecture layer is the core operating system layer, which includes memory management, file system, power management and some other operating system tasks. It can interact directly with the hardware device. As an app developer, you don't have to deal with this layer.
2. Core Services is the central service layer through which you can access some of the services of iOS.
3, media layer, through which we can use a variety of media files in the application, audio and video recording, graphic drawing, as well as the production of basic animation effect.
4. Cocoa Touch is a touch layer, a layer that provides a variety of useful frameworks for our application development, and most of it is about the user interface, which is essentially responsible for the user's touch interaction on the iOS device.
Android's system architecture
Android's system architecture, like its operating system, employs a layered architecture.
From the architecture view, Android is divided into four layers, from the upper to the lower level, respectively
Application Layer (applications)
Application Framework layer (application framework)
System Runtime Layer (Libraries and Android Runtime)
Linux core layer (Linux Kernel)
As shown in the following:
Android System Architecture parsing:
1> Linux kernel Layer
Based on the Linux operating system kernel, Android uses Linux kernel service to realize the core functions of hardware device driver, process and memory management, network protocol stack, power management, wireless communication and so on. Before the Android4.0 version was based on the Linux2.6 series kernel, the 4.0 and later versions used the updated linux3.x kernel, and two open source projects began to interoperate. The Linux3.3 kernel officially includes some Android code that can be directly booted into Android. Linux3.4 will add more features such as power management to increase hardware compatibility with Android and enable Android to be supported on more devices.
The Android kernel has enhanced the Linux kernel, adding some unique features for mobile computing. For example, the Low memory manager LMK (Keller), Anonymous shared memory (ASHMEM), and the lightweight interprocess communication binder mechanism. These kernel enhancements have enabled Android to further enhance the security of memory management, interprocess communication, and so on, while inheriting the Linux kernel security mechanism. The following table lists the main driver modules for the Android kernel:
Driver name Description
Android Power Management (Power Ma nagement)
Lightweight power management drivers for embedded devices, based on standard Linux power management systems
Low memory Manager (Keller)
You can kill the process as needed to free up the required memory. extended the oom mechanism of Linux to form a unique LMK mechanism
Anonymous shared memory (ASHMEM)
Provides shared memory resources between processes, while providing a mechanism for the kernel to reclaim and manage memory
Log (Android Logger)
A lightweight log device
Timers (Anroid Alarm)
Provides a timer to wake the device from sleep
Physical Memory mapping Management (Android Pmem)
DSP and other devices can only work on continuous physical memory, PMEM is used to provide continuous physical memory area mapping to user space
Android Timer devices (Android Timed device)
Can perform timing control functions on the device
YAFFS2 File System
Android uses large-capacity NAND flash memory as a storage device, using YAFFS2 as the file system to manage large-capacity MTD NAND FLASH;YAFFS2 takes up little memory and garbage collection is quick and simple.
Android Paranoid Network
The network code of the Linux kernel is changed, and the network authentication mechanism is added. It can be set in Ipv4,ipv6 and Bluetooth and is enabled by the Android_paranoid_network macro.
2> system run-level library layer
In the official system architecture diagram, the System runtime layer on top of the Linux kernel layer is the support of the application framework, which serves the various components in the Android system. The System runtime layer is composed of the System class library and the Android runtime.
- System Class Library
Most of the System class libraries are written in C + +, and the functionality provided is used by the developer through the Android application framework. The main system class libraries and descriptions are as follows:
System Class Library Name Description
Surface Manager
Display of the management subsystem when executing multiple applications, plus support for 2D and 3D graphics
Media Framework
The Packetvideoopencore-based multimedia library supports recording and playback of a variety of commonly used audio and video formats, including Mpeg4,mp3,h264,aac,arm
Sqlite
Local small relational database, Android provides some new SQLite database APIs to replace the traditional resource-intensive JDBC API
Opengl|es
3D cross-platform graphics library based on OpenGL ES 1.0API Standard
FreeType
Used to display bitmaps and vector fonts
Webkit
Software engine for Web browser
SGL
The underlying 2D graphics engine
LIBC (Bionic L IBC)
Inherits from BSD's C function library bionic libc, more suitable for embedded Linux-based mobile devices
Ssl
Secure Sockets Layer is a security protocol that provides security and data integrity for network communication
In addition to the main system class libraries listed in the table above, the Android NDK (Native development Kit), the Android native library, is also important. The NDK provides developers with an interface to directly use Android system resources and write programs in the C or C + + languages. As a result, third-party applications can be developed without relying on dalvik virtual machines. In fact, the NDK provides a range of tools needed to generate native code from C or C + +, facilitating rapid development of C or C + + dynamic libraries for developers, and the ability to automatically package the generated dynamic libraries and Java applications together into an application package file, the. apk file.
Note that the application Framework layer API cannot be accessed using native libraries, and compatibility may not be guaranteed. And from a security standpoint, the Android native library is written in a non-type-safe programming language c,c++, which is more prone to security vulnerabilities, and a bug in the native library may be more likely to directly affect the security of the application.
- Run-time
The Android runtime contains both the core library and the Dalvik virtual machine.
Core Library: The core library provides most of the functionality of the Java5 SE API and provides the core API for Android, such as Android.os,android.net,android.media.
Dalvik virtual machine: The Dalvik virtual machine is an Apache-based Java Virtual machine and is improved to accommodate low-memory, low-processor-speed mobile device environments. Dalvik virtual machines rely on the Linux kernel for process isolation and thread debug management, security and exception management, garbage collection and other important functions.
Essentially, the Dalvik virtual machine is not a Java Virtual machine (JVM) in the traditional sense. Dalvik virtual machines are not implemented in accordance with the specifications of the Java Virtual machine, and they are not compatible.
The following are the main differences between Dalvik and standard Java virtual machines:
The Dalvik is based on a register, and the JVM is stack-based. It is generally believed that the register-based implementation, although more dependent on the specific CPU structure, the hardware versatility is slightly worse, but its use of equal-length instructions, in terms of efficiency faster than the traditional JVM more advantages.
Dalvik is optimized to allow instances of multiple virtual machines to run efficiently in limited memory, and each Dalvik application executes as a standalone Linux process with a separate Dalvik virtual machine instance. Android, the Linux-based process "sandbox" mechanism, is one of the foundations of the entire security design.
The Dalvik virtual machine reads instructions and data from a file in Dex (Dalvik executable) format, which is interpreted to run. Dex files are generated by traditional, compiled class files that are processed by the DX tool software.
Dalvik's Dex files can also be further optimized to improve operational performance. Typically, an OEM application can generate the optimization file directly after the system compiles (. ODEX); third-party applications can be optimized and saved in the cache at run time, with the optimized format dey (. dey file).
3> Application Framework Layer
The application framework layer provides a range of class libraries that are required to develop Android applications, enabling developers to quickly develop applications, facilitate reuse of components, and allow for personalized extensions through inheritance. The specific modules are as follows:
The application framework Layer class library name functions as follows:
Event Manager (Activity Mananger)
Manage individual application lifecycles and provide common navigation fallback functionality for interfaces that interact with Windows for all Programs
Window Manager (Windows Manager)
Manage all open Windows programs
Content provider (contents Provider)
Provide one application with the ability to access another application's data, or implement data sharing between applications
View System
Create the basic components of your application, including lists (lists), grids (grids), text boxes (texts boxes), buttons (buttons), and web browsers that can be embedded.
Notification Manager (Notification Manager)
Enables applications to display customized customer tip information in the status bar
Package Manager
Manage applications, provide functions such as installing applications, uninstalling applications, querying related permissions, and more.
Resource Manager (Resource Manager)
Provides a variety of non-code resources for the use of programs such as localized strings, pictures, audio, etc.
Location Manager (Locator manager)
Provide location services
Phone Manager (Telephony manager)
Manage all your mobile device features
XMPP Service
is a common process in Google Online instant communication software, providing background push service
4> Application Layer
The application layer on the Android platform includes a variety of applications that interact directly with the user, or a service program written in the Java language that runs in the background. For example, the common basic function programs implemented on smartphones, such as SMS, phone dialing, picture browser, calendar, games, maps, Web browsers, and other applications developed by developers.
IOS vs Android System architecture