简体   繁体   English

两个页面条目引用同一物理页面

[英]Two page entries reference to the same physical page

For linux and windows, in the same process, how to make two page entries reference to the same physical page? 对于linux和Windows,在同一过程中,如何使两个页面条目引用同一物理页面?

For windows, by reading at the MSDN, looks like I can call CreateFileMapping by passing INVALID_HANDLE_VALUE to create a file mapping without backed by a file. 对于Windows,通过在MSDN上阅读,看来我可以通过传递INVALID_HANDLE_VALUE来创建文件映射而无需文件支持的方式来调用CreateFileMapping Then I can call MapViewOfFileEx twice with different lpBaseAddress , which essentially makes two different addresses reference to the same physical address. 然后,我可以使用不同的lpBaseAddress两次调用MapViewOfFileEx ,这实际上使两个不同的地址引用相同的物理地址。

My question is, how to do it under linux? 我的问题是,在Linux下如何做? I read manual for mmap , and didn't see a way to do it, unless the region is backed by a file (with flag MAP_SHARED ) but modifications to this region will be written to the file, which is not what I want. 我阅读了mmap手册,但没有找到解决方法,除非该区域由文件(带有标志MAP_SHARED )支持,但是对该区域的修改将写入该文件,这不是我想要的。 Does anyone aware of someway to do this? 有人知道这样做吗? I am not against backing by a file, as long as the writing to the region doesn't actually goes to the disk. 我不反对使用文件作为后盾,只要对该区域的写入实际上并没有写入磁盘。 Using tmpfs is not an option because I can't guarantee user has a tmpfs mounted. 不能使用tmpfs因为我不能保证用户安装了tmpfs

By the way, the code should be user mode code, not kernel mode. 顺便说一句,代码应该是用户模式代码,而不是内核模式。

Use shm_open() to create a file for mmap() . 使用shm_open()mmap()创建文件。

"I want to write some emulator" is the same purpose as mine when I used this trick. 使用此技巧时,“我想写一些模拟器”与我的目的相同。 I did use ipc/shm, but I forgot the detail. 我确实使用过ipc / shm,但是我忘记了细节。 It was very very very very probably: shmget()+shmat() 非常非常非常可能: shmget()+shmat()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 32 位物理页表分辨率 - 32-bit physical page table resolution 25% 使用物理 memory 时的页面错误 - Page faults when 25% used physical memory 为 Flutter 列表添加向上和向下翻页的物理键盘支持 - Add physical keyboard support for page up and page down to Flutter lists 如何判断Windows中两个地址是否在同一页面? - How to judge whether two addresses are in same page or not in Windows? 两个Windows / FF28.0框,同一页,同一台打印机,相同的设置,不同的打印输出? - Two Windows/FF28.0 boxes, same page, same printer, same settings, different printout? 有什么方法可以限制物理内存的使用? (页面文件可以) - Any way to limit physical memory usage? (Page file is OK) Windows中有关PTE(页表项)的信息 - Information about PTE's (Page Table Entries) in Windows 在页面/主页和子页面之间共享相同的视图模型 - Sharing the same viewmodel between pages/main page and sub-page 手动写入页表条目 (PTE) 时如何防止 Windows kernel 锁定 - How to prevent Windows kernel locking up when manually writing to page table entries (PTE) Windows Server 2003 SP2是否能说明有关免费系统页表项的真相? - Does Windows Server 2003 SP2 tell the truth about Free System Page Table Entries?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM