Ashmem is the driver module that Android has added on Linux, which means that Android does not have the functionality of Linux.
The Ashmem module is implemented at the kernel level and provides access interfaces at the runtime Library and application framework layer. At the runtime, the library layer provides a C + + interface, which is provided in the application framework layer as a Java interface.
First, starting from the analysis of the driver module, the driver module after loading first misc_register to register a ASHMEM_MISC device. This device file is "/dev/ashmem". This device provides four operations for the user layer open, mmap, release, IOCTL. But without the read and write operations, these two operations are implemented by MMAP.
-
- Open (): essentially creates a ashmem_area struct that returns to the file structure
Here is an example of a function execution process that creates an anonymous shared memory file.
Application Layer Class: Memoryfile constructor--"JNI function: native_open--" Runtime: ashmem_create_region--"Ashmem driver interface function: Open, ioctl--" Ashmem-driven functions: Ashmem_open, Ashmem_ioctl
Note that the driver interface here is ashmem_open in the corresponding driver, the IOCTL is corresponding to the ashmem_ioctl. I personally feel a bit like the Windows-driven IRP main function code for the same as the distribution function, do not know that this understanding is not right 0.0, of course, the Windows Application layer is a fixed function (such as WriteFile, and then by the I/O manager operation), is not customizable.
"Reading Notes" Android's ashmem mechanism learning