ashmem有哪些特殊功能? [英] What special powers does ashmem have?

查看:91
本文介绍了ashmem有哪些特殊功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以解释为什么创建了ahmem吗?

Can someone explain why ashmem was created?

我正在浏览mm/ashmem.c.据我所知,内核将ashmem视为可以映射的文件支持的内存.但是,为什么还要麻烦实施ashmem?通过安装RAM fs,然后使用filemap/mmap共享内存,似乎可以实现相同的功能.

I'm browsing through mm/ashmem.c right now. As near as I can tell, the kernel is thinking of ashmem as file-backed memory that can be mmap'd. But then, why go to the trouble of implementing ashmem? It seems like the same functionality could be achieved by mounting a RAM fs and then using filemap/mmap to share memory.

我确定ashmem可以做更多更有趣的事情-从查看代码来看,这似乎与固定/取消固定页面有关?

I'm sure that ashmem can do more fancy stuff -- from looking at the code, it seems to have something to do with pinning/unpinning pages?

推荐答案

Ashmem允许按祖先关系不相关的进程按名称共享内存映射,这些映射将自动清除.

Ashmem allows processes which are not related by ancestry to share memory maps by name, which are cleaned up automatically.

普通的旧匿名mmap和System V共享内存缺少其中一些要求.

Plain old anonymous mmaps and System V shared memory lack some of these requirements.

System V共享内存段在运行程序不再引用时会停留在周围(这有时是功能,有时是令人讨厌的事情).

System V shared memory segments stick around when no longer referenced by running programs (which is sometimes a feature, sometimes a nuisance).

匿名共享mmap可以从父进程传递到子进程,这是不灵活的,因为有时您希望与这种方式无关的进程共享内存.

Anonymous shared mmaps can be passed from a parent to child processes, which is inflexible since sometimes you want processes not related that way to share memory.

这篇关于ashmem有哪些特殊功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆