打印
[应用相关]

Programming for nommu Linux

[复制链接]
1458|11
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
wangjiahao88|  楼主 | 2018-8-7 09:32 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
Nomu Linux程序编程
沙发
wangjiahao88|  楼主 | 2018-8-7 09:33 | 只看该作者
A nommu system does not use a memory management unit, which is the part of the processor that translates virtual addresses into physical addresses. In a nommu system, all addresses are physical addresses, which means:

NoMMU系统不使用内存管理单元,它是将虚拟地址转换成物理地址的处理器的一部分。在NOMMU系统中,所有地址都是物理地址,这意味着:

使用特权

评论回复
板凳
wangjiahao88|  楼主 | 2018-8-7 09:33 | 只看该作者
No demand faulting: memory is allocated directly by malloc(), which returns NULL a lot more often.

无需求故障:内存直接由MalCube()分配,它经常返回空。

使用特权

评论回复
地板
wangjiahao88|  楼主 | 2018-8-7 09:33 | 只看该作者
In a system with an mmu, malloc() doesn't actually allocate memory. The new virtual address range starts with a redundant copy-on-write mapping of the "zero page" (so all reads return zero but are actually reading from the same physical page over and over), and then writes are intercepted and new memory allocated to hold them as needed by the page fault handler.

在具有MMU的系统中,MalCube()不实际分配内存。新的虚拟地址范围从“零页”的冗余拷贝写映射开始(因此所有的读都返回零,但实际上是从同一个物理页面一遍遍地读取),然后写入被截取,并根据页错误处理程序的需要分配新的内存来保存它们。

使用特权

评论回复
5
wangjiahao88|  楼主 | 2018-8-7 09:34 | 只看该作者
A nommu system hasn't got virtual address, any "mappings" are just the kernel keeping track of what physical memory is allocated and what's free. Instead allocations on nommu must locate a contiguous region of physical memory, memset it to zero, and return a pointer to the start of it. This means malloc() will return NULL if it can't find a sufficiently large contiguous chunk of memory.

This means that large speculative mappings, such as megabytes of stack "just in case", are a bad idea on nommu.

NoMu系统没有虚拟地址,任何“映射”只是跟踪物理内存分配和什么免费的内核。相反,NoMMU上的分配必须找到物理内存的邻接区域,将MSESET设置为零,并返回指向其开始的指针。这意味着如果无法找到足够大的连续内存块,则MalCube()将返回null。
这意味着大型投机映射,如“兆”的“兆”,对NoMMU来说是一个坏主意。

使用特权

评论回复
6
wangjiahao88|  楼主 | 2018-8-7 09:34 | 只看该作者
All program text must be relocatable: so we can't use standard ELF binaries.

Every process in a nommu system uses/sees the same addresses. Most ELF programs specify what address to map each segment at, and the code/data in those segments uses fixed addresses, (plus other details like the program's entry point). This doesn't work on nommu because you don't know what other programs are running on the system, and if you want to run two instances of the same program each needs its own bss and data segments.

所有的程序文本必须是可重新定位的:所以我们不能使用标准的ELF二进制文件。
NoMu系统中的每个进程都使用/看到相同的地址。大多数ELF程序指定要映射每个段的地址,这些段中的代码/数据使用固定地址(加上程序的入口点等其他细节)。这在NoMMU上不起作用,因为您不知道系统上运行的其他程序,如果要运行同一程序的两个实例,每个程序都需要自己的BSS和数据段。

使用特权

评论回复
7
wangjiahao88|  楼主 | 2018-8-7 09:35 | 只看该作者
总结一下:
1.没有mmu的机器将会使用直接使用物理地址,所有程序将使用统一的地址空间
2.所有的应用程序必须编译成完全可重定向,就是动态链接库的编译原理,这样程序就可以被加载到任何地址运行
3.编译阶段必须固定栈区大小还必须要小,不然分配内存会有很大问题
4.内存频繁使用后将产生大量的内存碎片

简单的说多跑两次程序可能就没有足够多的连续空间可以用的了,看来没有mmu跑linux最大的问题还是内存碎片,现在也没什么好的解决方案

使用特权

评论回复
8
不爱说话| | 2018-8-7 10:34 | 只看该作者
最近关注STM32 Linux的人多起来了:)

使用特权

评论回复
9
wangjiahao88|  楼主 | 2018-8-7 11:25 | 只看该作者
cxlinx吧!

使用特权

评论回复
10
keaibukelian| | 2018-8-7 12:54 | 只看该作者
请问 Nomu 是什么啊

使用特权

评论回复
11
labasi| | 2018-8-7 12:55 | 只看该作者
我没看明白 新出的东西吗?

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

473

主题

7517

帖子

30

粉丝