Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kernel mode下的内存读取方式 #53

Open
eason-777 opened this issue Feb 15, 2022 · 3 comments
Open

kernel mode下的内存读取方式 #53

eason-777 opened this issue Feb 15, 2022 · 3 comments

Comments

@eason-777
Copy link

当进入main函数之后,第一次fork之前,也就是第二章的主要内容,已经进入了protected mode,为什么还能直接读取实地址下的值呢?例如“第16回控制台初始化”一节中,可以读取0x90000处的光标地址。这个时候已经处于protected mode了,这个地址是一个线性地址,会被TLB转换成物理地址,也就是另一个地址。
我肯定是某处想错了,请大佬们纠正!谢谢。

@eason-777
Copy link
Author

eason-777 commented Feb 15, 2022

我总把分页和虚拟内存绑在一起想,我的理解是“开启分页之后,虚拟内存也自动开启了”,不知道这种想法对不对。

@eason-777
Copy link
Author

eason-777 commented Feb 15, 2022

破案了。“能直接用线性地址0x90000当作物理地址”的原因在“第9回”中解释了,因为linux0.11假设了内存空间只有16M,页目录表中4项,每张页表1024项,就能表达4 * 1024 * 1024 * (4 * 1024)=16M,恰好能使得线性地址和物理地址是一一对应的关系。
至于分页是否和虚拟内存总是绑定在一起,我认为答案是肯定的,因为分页就是为了突破物理内存的限制而产生,也就是说是为virtual memory而产生。虽然在此处可以忽略虚拟内存,因为分页之后的线性空间和物理空间大小一致了。

@eason-777
Copy link
Author

btw, 第9回中,“15M线性地址转换成物理地址”的例图应该是出错了,是13M。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant