因仑“3+1”工程特种兵精英论坛

标题: 虚拟内存实践 [打印本页]

作者: leixiaofeng    时间: 2015-3-22 20:14
标题: 虚拟内存实践

实现目的: 通过实验了解虚拟内存


实验内容:在proc 文件系统下,我们建立一个文件,每次向这个文件写人字符时,调用相应的虚拟内存处理函数






下面为Makefile


view plaincopy to clipboardprint?



下面为测试用例

[root@HBIDS proc]# echo "listvma" > mtest
[root@HBIDS proc]# echo "listvma" > mtest
[root@HBIDS proc]# echo "findvma0xb7f2b001" > mtest
[root@HBIDS proc]# echo "findpage0xb7f2b001" > mtest
[root@HBIDS proc]# echo "writeval0xb7f2b001 123456" > mtest

打印结果为

The current process is bash
mtest_dump_vma_list
VMA 0x8048000-0x80dc000 READ EXEC
VMA 0x80dc000-0x80e2000 WRITE READ EXEC
VMA 0x80e2000-0x811e000 WRITE READ EXEC
VMA 0x42000000-0x4212e000 READ EXEC
VMA 0x4212e000-0x42131000 WRITE READ EXEC
VMA 0x42131000-0x42133000 WRITE READ EXEC
VMA 0xb7d00000-0xb7f00000 READ EXEC
VMA 0xb7f00000-0xb7f0b000 READ EXEC
VMA 0xb7f0b000-0xb7f0c000 WRITE READ EXEC
VMA 0xb7f0c000-0xb7f0d000 WRITE READ EXEC
VMA 0xb7f0d000-0xb7f0f000 READ EXEC
VMA 0xb7f0f000-0xb7f10000 WRITE READ EXEC
VMA 0xb7f10000-0xb7f13000 READ EXEC
VMA 0xb7f13000-0xb7f14000 WRITE READ EXEC
VMA 0xb7f2b000-0xb7f31000 READ EXEC
VMA 0xb7f31000-0xb7f32000 WRITE READ EXEC
VMA 0xb7f32000-0xb7f47000 READ EXEC
VMA 0xb7f47000-0xb7f48000 WRITE READ EXEC
VMA 0xbfd31000-0xbfd47000 WRITE READ EXEC
mtest_write  ...........
mtest_find_vma
found vma 0xb7f47000-0xb7f48000 flag 100877 for addr 0xb7f47001
mtest_write  ...........
mtest_write_val
page  found  for 0xb7f47001
find  0xb7f47001 to kernel address 0xc8c4e001
mtest_write  ...........
mtest_write_val
write 0x1234 to address 0xc8c4e001







欢迎光临 因仑“3+1”工程特种兵精英论坛 (http://bbs.enlern.com/) Powered by Discuz! X3.4