Linux prefers paging to segmentation info coreutils 'ls invocation'

本文探讨了程序员控制内存映射以实现多个进程共享内存的技术。通过共享内存区域,进程间可以进行高带宽通信,减少数据复制,并用于高性能消息传递系统。还介绍了分布式共享内存等高级内存管理技术。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

One reason for giving programmers control over their memory map is to allow two or more
processes to share the same memory. If programmers can name regions of their memory, it may be
possible for one process to give another process the name of a memory region so that process can
also map it in. With two (or more) processes sharing the same pages, high bandwidth sharing
becomes possible: one process writes into the shared memory and another one reads from it.
Sharing of pages can also be used to implement a high-performance message passing system.
Normally, when messages are passed, the data are copied from one address space to another, at
considerable cost. If processes can control their page map, a message can be passed by having the
sending process unmap the page(s) containing the message, and the receiving process mapping them
in. Here only the page names have to be copied, instead of all the data.
Yet another advanced memory management technique is distributed shared memory (Feeley et al.,
1995; Li and Hudak, 1989; and Zekauskas et al., 1994). The idea here is to allow multiple processes
over a network to share a set of pages, possibly, but not necessarily, as a single shared linear address
space. When a process references a page that is not currently mapped in, it gets a page fault. The
page fault handler, which may be in the kernel or in user space, then locates the machine holding the
page and sends it a message asking it to unmap the page and send it over the network. When the
page arrives, it is mapped in and the faulting instruction is restarted.


The GFP_KERNEL parameter is an example of a gfp_mask flag. It is discussed shortly.
Make note of the error checking after the call to __get_free_pages().A kernel allocation
can fail, and your code must check for and handle such errors.
This might mean
unwinding everything you have done thus far. It therefore often makes sense to allocate
your memory at the start of the routine to make handling the error easier.


vmalloc() is used
only when absolutely necessary—typically, to obtain large regions of memory. For example,
when modules are dynamically inserted into the kernel, they are loaded into memory
created via vmalloc().


 Linux prefers paging to
segmentation for the following reasons:

Is sharing of procedures   between users facilitated?
    No Yes
    Why was this technique   invented?
    paging is To get a large    linear address    space without    having to buy    more physical    memory
    segmenting is To allow programs and    data to be broken up    into logically    independent address   spaces and to aid    sharing and protection


RAM

There are special nonvolatile RAMs that integrate a battery-backup system,
such that the RAM remains powered even when the rest of the computer system has shut down.


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值