| 
View
 

ASHMEM

This version was saved 11 years, 4 months ago View current version     Page history
Saved by debrasantorini
on September 19, 2013 at 7:33:31 am
 

Anonymous SHared MEMory, or ASHMEM, is a named memory block that is shared between processes that the kernel is allowed to free. This is notable as the kernel is not allowed to free standard shared memory.

 

ASHMEM is allocated and used as follows:

 

fd = ashmem_create_region("my_shm_region", size);

if(fd < 0)

  return -1;

data = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);

if(data == MAP_FAILED)

  goto out;

 

However for security reasons other processes cannot access this region by name (my_shm_region).  The file descriptor pointing to this shared memory region is actually passed through the IPC Binding interface. Concrete examples found in IMemory.h.

 

Source: Android Platform Google Groups http://bit.ly/1vnP69

 

ASHMEM vs PMEM: "ashmem and pmem are very similar. Both are used for sharing memory between processes. ashmem uses virtual memory, whereas pmem uses physically contiguous memory. One big difference is that with ashmem, you have a ref-counted object that can be shared equally between processes. For example, if two processes are sharing an ashmem buffer, the buffer reference goes away when both process[es] have removed all their references by closing all their file descriptors. pmem doesn't work that way because it needs to maintain a physical to virtual mapping of. This requires the process that allocates a pmem heap to hold the file descriptor until all the other references are closed.

 

[...] The choice between ashmem and pmem     Payment Gateways depends on whether you need physically contiguous buffers. In the case of the G1 [T-Mobile's Android phone], we use the hardware 2D engine to do scaling, rotation, and color conversion, so we use pmem heaps. The emulator doesn't have a pmem driver and doesn't really need one, so we use ashmem in the emulator. If you use ashmem on the G1, you lose the hardware 2D engine capability [...]"

Source: android-framework mailing list http://bit.ly/Jk7HP 

игровые автоматы:игровые автоматы бесплатно

 

The Java-based high-level ASHMEM wrapper: http://developer.android.com/reference/android/os/MemoryFile.html

no deposit casino

 

www.backgroundnow.com

texas is the second most populous and the second-largest of the 50 states in the United States of America, and the largest state in the 48 contiguous states!

Comments (0)

You don't have permission to comment on this page.