Segmentation & Paging

虚拟内存

通过虚拟内存结合内存分段和分页,形成段页式内存。段面向用户、页面向硬件
notion image
notion image

载入内存的过程

notion image

1、分割虚拟内存、建立段表

notion image
此处ldt[1]ldt[2]分别是代码段和数据段,分配64M虚拟内存;nr是进程号
notion image
简化:每个进程占用地址空间互不重叠,可以使每个进程对应的页也不重叠。这样在切换进程时可以不切换页表
在实际的操作系统中页号是很可能重叠的,每个进程需要有自己的段表和页表

2、分配内存、建页表

分配内存已经在上一部完成。这里父进程和子进程使用不同的虚拟内存但占用相同的页.
notion image
from>>22 * 4 ⇒ from>>20 并把最后两位置为0,4是每项4个字节
notion image
notion image
完成后
notion image

3、使用内存

notion image