- Изучаем Android. Ядро (Kernel) — что это такое.
- What is a kernel?
- Samsung needs to bring back its iPod competitor
- VoLTE: How to use it and why you should care
- PlayStation reportedly planning service to compete with Xbox Game Pass
- These are the best rugged Android phones
- Android Kernel Features
- Contents
- Kernel features unique to Android
- Resources
- Temporary including in mainline ‘staging’
- Android mainlining project
- List of kernel features unique to Android
- Binder
- ashmem
- logger
- wakelocks
- oom handling
- Alarm timers
- POSIX Alarm Timers
- paranoid network security
- timed output / timed gpio
- RAM_CONSOLE
- other kernel changes
Изучаем Android. Ядро (Kernel) — что это такое.
Многие владельцы Android устройств на различных форумах и сайтах часто встречают упоминание о чем-то непонятном, что называют ядром, или по-английски kernel. Его можно поменять и упоминание о нем встречается в меню настроек устройства, в разделе «О планшете (телефоне)».
Если копнуть поглубже, то окажется, что ядро – это часть операционной системы, и оно есть не только у Android, но и у других операционных систем: Windows, iOS, MacOS и прочих. Но нас будет интересовать ядро Android, и что это такое я попытаюсь объяснить на уровне начинающих пользователей.
Вы, наверное, знаете, что любая операционная система, и Android в том числе – это, по большому счету, набор программ, которые управляют работой всего устройства, и отвечают за запуск пользовательских приложений, таких как игры, менеджеры файлов, веб-браузеры и прочие.
А ядро Android является, практически, самой главной частью операционной системы, которая отвечает за взаимодействие между всем «железом» и программной частью системы. Ядро состоит из набора драйверов всего имеющегося в устройстве оборудования и подсистемы управления памятью, сетью, безопасностью, и прочих основных функций операционной системы.
Например, когда вы касаетесь экрана, чтобы запустить какое-либо приложение, драйвер сенсорной панели экрана определяет место, в котором произошло нажатие и сообщает координаты другим программам, которые опять же с помощью ядра найдут в памяти устройства нужное приложение и запустят его. Это конечно, очень упрощенная модель, но суть работы операционной системы она отражает.
Таким образом, мы выяснили, что когда любое программное обеспечение нуждается в том, чтобы оборудование планшета или телефона что-нибудь сделало, оно обращается за этим к ядру операционной системы.
Ядро управляет абсолютно всем оборудованием: Wi-Fi, Bluetooth, GPS, памятью и прочими устройствами. Не является исключением и «сердце» устройства – его процессор. Ядро может управлять его частотой и энергоснабжением.
Ядро операционной системы Android, позаимствовано ее разработчиками, компанией Google, у операционной системы Linux.
Так как ядро управляет всем оборудованием, а оборудование у всех планшетов и телефонов разное, базовое ядро Android дорабатывается производителем для каждого устройства отдельно.
Как и прошивки, ядра бывают стоковыми (заводскими) и кастомными – альтернативными, созданные независимыми разработчиками.
Зачем нужны кастомные ядра? Стоковое ядро максимально оптимизируется производителем для конкретного устройства, но в нем обычно заблокированы такие важные функции ядра, как, например, управление частотой процессора. И если вам понадобится разогнать процессор своего планшета, вам нужно будет сменить ядро на кастомное, в котором функция управления частотой процессора разблокирована.
Кроме того, кастомные ядра, обычно основаны на более свежих версиях Linux ядер. Вот примерный перечень возможностей, которые нам дают кастомные ядра:
- Изменение частоты процессора в широких пределах;
- Разгон графической подсистемы (GPU);
- Снижение частоты и напряжения питания процессора, что позволяет достичь более длительного времени работы от батареи;
- Более свежие и качественные драйверы, например, ускоряющие работу GPS или добавляющие новые функции;
- Широкие возможности по настройки и конфигурации звука и цветовой гаммы экрана;
- Поддержка альтернативных файловых систем (XFS, ReiserFS и прочих).
Так как альтернативные ядра создаются независимыми разработчиками, нет никакой гарантии, что после установки кастомного ядра ваш планшет или телефон будут работать без сбоев. Поэтому перед прошивкой нового ядра желательно сделать полную резервную копию системы.
Источник
What is a kernel?
What is a kernel? If you spend any time reading Android forums, blogs, how-to posts or online discussion you’ll soon hear people talking about the kernel. A kernel isn’t something unique to Android — iOS and MacOS have one, Windows has one, BlackBerry’s QNX has one, in fact all high level operating systems have one. The one we’re interested in is Linux, as it’s the one Android uses. Let’s try to break down what it is and what it does.
Android devices use the Linux kernel, bet every phone uses their own version of it. Linux kernel maintainers keep everything tidy and available, contributors (like Google) add or alter things to better meet their needs, and the people making the hardware contribute as well, because they need to develop hardware drivers for the parts they’re using for the kernel version they’re using. This is why it takes a while for independent Android developers and hackers to port new versions to older devices and get everything working. Drivers written to work with one version of the kernel for a phone might not work with a different version of software on the same phone. And that’s important, because one of the kernel’s main functions is to control the hardware. It’s a whole lot of source code, with more options while building it than you can imagine, but in the end it’s just the intermediary between the hardware and the software.
When software needs the hardware to do anything, it sends a request to the kernel. And when we say anything, we mean anything. From the brightness of the screen, to the volume level, to initiating a call through the radio, even what’s drawn on the display is ultimately controlled by the kernel. For example — when you tap the search button on your phone, you tell the software to open the search application. What happens is that you touched a certain point on the digitizer, which tells the software that you’ve touched the screen at those coordinates. The software knows that when that particular spot is touched, the search dialog is supposed to open. The kernel is what tells the digitizer to look (or listen, events are «listened» for) for touches, helps figure out where you touched, and tells the system you touched it. In turn, when the system receives a touch event at a specific point from the kernel (through the driver) it knows what to draw on your screen. Both the hardware and the software communicate both ways with the kernel, and that’s how your phone knows when to do something. Input from one side is sent as output to the other, whether it’s you playing Angry Birds, or connecting to your car’s Bluetooth.
It sounds complicated, and it is. But it’s also pretty standard computer logic — there’s an action of some sort generated for every event, and depending on that action things happen to the running software. Without the kernel to accept and send information, developers would have to write code for every single event for every single piece of hardware in your device. With the kernel, all they have to do is communicate with it through the Android system API’s, and hardware developers only have to make the device hardware communicate with the kernel. The good thing is that you don’t need to know exactly how or why the kernel does what it does, just understanding that it’s the go-between from software to hardware gives you a pretty good grasp of what’s happening under the glass.
Sort of gives a whole new outlook towards those fellows who stay up all night to work on kernels for your phone, doesn’t it?
Samsung needs to bring back its iPod competitor
I don’t want to buy an iPod Touch. Since I want a reasonably priced PMP with acceptable audio hardware that can install a few crucial apps, I might have to.
VoLTE: How to use it and why you should care
VoLTE — or Voice over LTE — is the new standard for calling throughout the U.S., Canada, and parts of Europe. Not only does it facilitate much higher call quality between cell phones, but it allows devices to stay connected to LTE while on a call, improving data speeds for everyone.
PlayStation reportedly planning service to compete with Xbox Game Pass
Sony is planning to create a service similar to Xbox Game Pass, according to a new report. The service could launch as early as sometime in the spring of 2022, with multiple tiers.
These are the best rugged Android phones
Living the rough and tumble life? Get yourself a smartphone that can handle everything you throw at it — or throw your phone at.
Источник
Android Kernel Features
Contents
Kernel features unique to Android
In the course of development, Google developers made some changes to the Linux kernel. The amount of changes is not extremely large, and is on the order of changes that are customarily made to the Linux kernel by embedded developers (approximately 250 patches, with about 3 meg. of differences in 25,000 lines). The changes include a variety of large and small additions, ranging from the wholesale addition of a flash filesystem (YAFFS2), to very small patches to augment Linux security (paranoid networking patches).
Various efforts have been made over the past few years to submit these to changes to mainline (mostly by Google engineers, but also by others), with not much success so far.
Resources
A very good overview of the changes is available in a talk by John Stultz at ELC 2011. (The talk has a somewhat misleading name.)
- Android OS for Servers- John Stultz, ELC 2011
- This talks breaks down the differences between an Android Linux kernel and a stock Linux kernel, and provides information about the features of each.
- http://www.lindusembedded.com/blog/2010/12/07/android-linux-kernel-additions/
- Lindus Embedded (Alex Gonzalez) has a listing of kernel changes based on an Android kernel for the Freescale MX51 SOC, with some good information about each change.
- http://yidonghan.wordpress.com/2010/01/28/porting-android-to-a-new-device/
- Peter McDermott’s excellent description of his work to port Android to the Nokia N810.
- Also, see his annotated list of modified and added kernel files, at: http://www.linuxfordevices.com/files/misc/porting-android-to-a-new-device-p3.html
- See the project site at sourceforge.
- http://www.slideshare.net/jollen/android-os-porting-introduction
- Jollen Chen’s excellent presentation on system-level Android features, including an overview of kernel features unique to Android: Note: Parts of the presentation are in Chinese
Temporary including in mainline ‘staging’
Some changes were temporarily added at the «staging» driver area in the stock kernel, but were removed due to lack of support. See Greg KH blog post on -staging for 2.6.33, where he announces the removal of various Android drivers from -staging.
Android mainlining project
Several groups and individuals are working to get kernel changes from Android mainlined into the Linux kernel.
Please see Android Mainlining Project for more information.
List of kernel features unique to Android
Here is a list of changes/addons that the Android Project made to the linux kernel. As of September, 2011, these kernel changes are not part of the standard kernel and are only available in the Android kernel trees in the Android Open Source project.
This list does not include board- or platform-specific support or drivers (commonly called «board support»).
Binder
Binder is an Android-specific interprocess communication mechanism, and remote procedure call system similar to DBus.
ashmem
- ashmem — Android shared memory
- implementation is in mm/ashmem.c
According to the Kconfig help «The ashmem subsystem is a new shared memory allocator, similar to POSIX SHM but with different behavior and sporting a simpler file-based API.»
Apparently it better-supports low memory devices, because it can discard shared memory units under memory pressure.
To use this, programs open /dev/ashmem, use mmap() on it, and can perform one or more of the following ioctls:
- ASHMEM_SET_NAME
- ASHMEM_GET_NAME
- ASHMEM_SET_SIZE
- ASHMEM_GET_SIZE
- ASHMEM_SET_PROT_MASK
- ASHMEM_GET_PROT_MASK
- ASHMEM_PIN
- ASHMEM_UNPIN
- ASHMEM_GET_PIN_STATUS
- ASHMEM_PURGE_ALL_CACHES
From a thread on android-platform source
You can create a shared memory segment using:
In the second process, instead of opening the region using the same name, for security reasons the file descriptor is passed to the other process via binder IPC.
The libcutils interface for ashmem consists of the following calls: (found in system/core/include/cutils/ashmem.h)
- int ashmem_create_region(const char *name, size_t size);
- int ashmem_set_prot_region(int fd, int prot);
- int ashmem_pin_region(int fd, size_t offset, size_t len);
- int ashmem_unpin_region(int fd, size_t offset, size_t len);
- int ashmem_get_size_region(int fd);
- PMEM — Process memory allocator
- implementation at: drivers/misc/pmem.c with include file at: include/linux/android_pmem.h
- Brian Swetland says:
David Sparks wrote the following: source
logger
- logger — system logging facility
- This is the kernel support for the ‘logcat’ command
- The kernel driver for the serial devices for logging are in the source code drivers/misc/logger.c
- See Android logger for more information about the kernel code
- See Android Logging System for an overview of the system it supports
wakelocks
- wakelock — used for power management files kernel/power/wakelock.c
- Holds machine awake on a per-event basis until wakelock is released
- See Android Power Management for detailed information
oom handling
- oom handling modifications
- lowmem notifications
- implementation at: drivers/misc/lowmemorykiller.c
- also at: security/lowmem.c
Informally known as the Viking Killer, the OOM handler simply kills processes as available memory becomes low. The kernel module follows rules for this that are supplied from user space in two ways:
1. init writes information about memory levels and associated classes:
- The write value must be consistent with the above properties.
- Note that the driver only supports 6 slots, so we have combined some of the classes into the same memory level; the associated processes of higher classes will still be killed first.
- From /init.rc:
2. User space sets the oom_adj of processes to put them in the correct class for their current operation. This redefines the meaning of oom_adj from that used by the standard OOM killer to something that is more aggressive and controlled.
These oom_adj levels end up being based on the process lifecycle defined here: http://developer.android.com/guide/topics/fundamentals.html#proclife
Alarm timers
This is the kernel implementation to support Android’s AlarmManager. It lets user space tell the kernel when it would like to wake up, allowing the kernel to schedule that appropriately and come back (holding a wake lock) when the time has expired regardless of the sleep state of the CPU.
POSIX Alarm Timers
Note that POSIX Alarm timers, which implement this functionality (but not identically), was accepted into mainline Linux in kernel version 3.0.
paranoid network security
- paranoid network security
- See Android_Security#Paranoid_network-ing
timed output / timed gpio
Generic gpio is a mechanism to allow programs to access and manipulate gpio registers from user space.
Timed output/gpio is a system to allow chaning a gpio pin and restore it automatically after a specified timeout. See drives/misc/timed_output.c and drives/misc/timed_gpio.c This expose a user space interface used by the vibrator code.
On ADP1, there is a driver at:
Also, there is a device at:
RAM_CONSOLE
This allows saving the kernel printk messages to a buffer in RAM, so that after a kernel panic they can be viewed in the next kernel invocation, by accessing /proc/last_kmsg.
[Would be good to get more details on how to set this up and use it here!] [I guess this is something like pramfs?]
other kernel changes
Here is a miscellaneous list of other kernel changes in the mistral Android kernel:
Источник