English 中文(简体)
Linux内核如何交换映射文件的页面?
原标题:How do the Linux kernel swap the file mapped page?

我使用文件映射来读取一个20GB的文件。当主存储器用尽时,内核如何将文件映射的页面交换到磁盘上?

我猜可能的方式是将页面条目设置为NULL。那么下一次访问页面时,将再次调用“do_no_page()”函数将文件映射到内存。是这样吗?

另一个问题是内核用于交换内存页面的优先级是什么?正常的页面还是映射文件的页面?

问题回答

页面表中每个条目都有一个无效位。当页面交换到硬盘时,其无效位被设置。每当访问页面时,MMU(处理器内存管理单元)会引发异常,系统负责重新将页面加载到内存中。然后重新执行有故障的指令。

Usually pages that are swapped are the pages that are not frequently accessed. There is another bit in each page table entry to know whenever a page has been accessed. How to choose the right page to swap with this single bit is a big problem, there is a whole chapter about this in the very good operating systems by Andrew Tanenbaum.

你可以使用mlock()系统调用将页面锁定到RAM内存中。如果你使用mmap()在内存中映射文件,可以使用MAP_LOCKED标志来完成(参见手册)。





相关问题
Signed executables under Linux

For security reasons, it is desirable to check the integrity of code before execution, avoiding tampered software by an attacker. So, my question is How to sign executable code and run only trusted ...

encoding of file shell script

How can I check the file encoding in a shell script? I need to know if a file is encoded in utf-8 or iso-8859-1. Thanks

How to write a Remote DataModule to run on a linux server?

i would like to know if there are any solution to do this. Does anyone? The big picture: I want to access data over the web, using my delphi thin clients. But i´would like to keep my server/service ...

How can I use exit codes to run shell scripts sequentially?

Since cruise control is full of bugs that have wasted my entire week, I have decided the existing shell scripts I have are simpler and thus better. Here is what I have so far svn update /var/www/...

Good, free, easy-to-use C graphics libraries? [closed]

I was wondering if there were any good free graphics libraries for C that are easy to use? It s for plotting 2d and 3d graphs and then saving to a file. It s on a Linux system and there s no gnuplot ...

热门标签