Get your own free workspace
View
 

ASHMEM

Page history last edited by Bernhard Rosenkraenzer 3 months, 1 week ago Saved with comment

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 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

Comments (3)

hollyleo said

at 11:44 pm on Jan 5, 2012

I have been seeking information on this topic for the past few hours and found your post to be well written and has solid information.
<a href="http://www.clubmz.com/">Cell Phone Spy</a>

thomasdelange said

at 9:38 am on May 8, 2012

http://www.hello3dworld.com/vi/category/-228/thiet-bi-van-phong.plg
http://www.hello3dworld.com/vi/category/-245/loa-ampli.plg
http://www.hello3dworld.com/vi/san-pham-3d/8037/dau-dia-bluray-sony-bdp-s350.plg
http://www.hello3dworld.com/vi/san-pham-3d/4939/dau-dia-tien-dat-dvd-818.plg
http://www.hello3dworld.com/vi/category/-301/mac-mini.plg
http://www.hello3dworld.com/vi/category/-300/imac.plg
http://www.hello3dworld.com/vi/san-pham-3d/4899/apple-macbook-pro-13inch.plg
http://www.hello3dworld.com/vi/category/-245/loa-ampli.plg
http://www.hello3dworld.com/vi/products/7155/tranh-thu-phap-chu-cha-me.plg
http://www.hello3dworld.com/vi/products/7299/tranh-son-dau-phong-canh-trang.plg
http://www.hello3dworld.com/vi/category/-233/son-nuoc.plg
http://www.hello3dworld.com/vi/products/7549/loa-vi-tinh-soundmax-a120.plg
http://www.hello3dworld.com/en/3d-offices-categories/216/fertilizer.plg
http://www.hello3dworld.com/vi/category/89/tv.plg
http://www.hello3dworld.com/vi/products/4923/dau-dia-tien-dat-dvd-k626.plg
http://www.hello3dworld.com/en/3D-products/1095/samsung-plasma-tv-ps50c7000.plg
http://www.hello3dworld.com/vi/products/610/tivi-sony-lcd-bravia-klv-32v400a-b.plg
http://www.hello3dworld.com/vi/products/1103/tivi-samsung-3d-led-ua55c8000.plg
http://www.hello3dworld.com/vi/san-pham-3d/4939/dau-dia-tien-dat-dvd-818.plg
http://www.hello3dworld.com/vi/products/4925/dau-dia-tien-dat-dvd-k630.plg
http://www.hello3dworld.com/vi/san-pham-3d/7414/dau-dia-dvd-sony-dvp-ns618p.plg
http://www.hello3dworld.com/vi/products/4899/apple-macbook-pro-13inch.plg
http://www.hello3dworld.com/vi/products/4914/apple-mac-pro-24ghz-quad-core-1tb.plg
http://www.hello3dworld.com/vi/san-pham-3d/8082/may-quay-phim-sony-dcr-sx21.plg
http://www.hello3dworld.com/vi/products/533/may-quay-o-cung-hdd-sony-hdr-xr550e.plg
http://www.hello3dworld.com/vi/products/314/dien-thoai-nokia-e5.plg
http://www.hello3dworld.com/vi/products/4912/apple-mac-mini-24ghz.plg

thomasdelange said

at 9:42 am on May 8, 2012

http://www.hello3dworld.com/vi/san-pham-3d/8036/amply-sony-bdv-e880w.plg
http://www.hello3dworld.com/vi/products/7153/noi-that-vinh-my-tu-bep-go-soi-1.plg
http://www.hello3dworld.com/vi/home.plg
http://www.hello3dworld.com/vi/category/-256/gom-su.plg
http://www.hello3dworld.com/vi/products/7299/tranh-son-dau-phong-canh-trang.plg
http://www.hello3dworld.com/vi/products/7155/tranh-thu-phap-chu-cha-me.plg
http://www.fxdialogue.com/
http://vieclamthuctap.com
http://diendanseopanda.forumvi.com
http://augustijncommunity.blogspot.com
http://360xu.blogspot.com
http://timeshare360xu.blogspot.com
http://saigontechforum.ucoz.com
http://www.raovat3d.org
http://360xu.blogspot.com/p/download-film.html
http://360xu.blogspot.com/2011/03/cach-tao-blog.html
http://www.dichvuseo.n.nu/seo-services
http://www.dichvuseo.n.nu/cong-cu-seo
http://www.dichvuseo.n.nu
http://www.thietkewebsite.n.nu
http://www.dichvuseo.n.nu/bang-gia-seo
http://timeshare360xu.blogspot.com
http://www.dichvuseo.n.nu/cong-ty-seo
http://shockingnewspics.blogspot.com/
http://www.dichvuseo.n.nu/dich-vu-seo
http://www.thietkewebsite.n.nu/thiet-ke-web
http://www.hello3dworld.com
http://360xu.blogspot.com/2011/04/shocking-news-stunning-funny-pictures.html
http://www.dichvuseo.n.nu/dich-vu-bao-tri-seo
http://www.dichvuseo.n.nu/link-building-services
http://www.vieclamthuctap.com/f11-thuc-tap-su-pham
http://www.vieclamthuctap.com/t11-thuc-tap-sinh-it
http://www.vieclamthuctap.com/c3-viec-lam-cho-sinh-vien-moi-ra-truong
http://www.vieclamthuctap.com/t1394-viec-lam-them-ngoai-gio-hanh-chinh
http://www.vieclamthuctap.com/f23-viec-lam-online-viec-lam-tai-nha
http://www.vieclamthuctap.com/t35-viec-lam-ban-thoi-gian-thu-nhap-cao-cong-ty-cp-dich-vu-bo-cau
http://www.vieclamthuctap.com/t45-viec-lam-them-tet-2012
http://www.vieclamthuctap.com/t108-thuc-tap-ke-toan-cho-sinh-vien-moi-ra-truong
http://seopandaagency.org/
http://seopandaagency.org/2012/04/02/dich-vu-seo-gia-re-uy-tin
http://seopandaagency.blog.com

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