page对保护的作用
昨天看了些page的東西,開(kāi)眼界了。趕緊總結(jié)記下來(lái),可別忘了。
Page Hardware Protection Scheme:
在頁(yè)表項(xiàng)中的后12位,具體可看intel documentation,這里只說(shuō)比較酷的跟用戶有關(guān)的幾個(gè)位。
User/Supervisor ------? When this flag is 0, the page can be addressed only when the CPL is less than 3 (this means, for Linux, when the processor is in Kernel Mode). When the flag is 1, the page can always be addressed.
Read/Write ----- If the Read/Write flag of a Page Directory or Page Table entry is equal to
0, the corresponding Page Table or page can only be read; otherwise it can be read and
written.
這里便想起了,
1 以前寫(xiě)的程序,會(huì)對(duì)read-only data 進(jìn)行寫(xiě)操作,便會(huì)產(chǎn)生segmentation fault.這里估計(jì)就是把read-only data放到了一個(gè)read-only page里面了。
2 還有如果對(duì)數(shù)組a[100]不斷的進(jìn)行寫(xiě)操作,也許當(dāng)?shù)絠ndex=1000時(shí)候,才會(huì)報(bào)segmentation fault。這是因?yàn)橹斑€是一直在read-write page里面操作,后來(lái)出了這個(gè)page了。(要么這個(gè)page不允許寫(xiě),要么這個(gè)page的內(nèi)存還沒(méi)有申請(qǐng),所以page fault了。)
轉(zhuǎn)載于:https://www.cnblogs.com/jack204/archive/2011/10/19/2217870.html
總結(jié)
以上是生活随笔為你收集整理的page对保护的作用的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: Delphi TStream 详细介绍
- 下一篇: 总结!进入libvirt的虚拟化世界(一