> For the complete documentation index, see [llms.txt](https://lfool.gitbook.io/operating-system/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lfool.gitbook.io/operating-system/di-san-zhang-nei-cun-guan-li/5.-cun-chu-bao-hu.md).

# 5. 存储保护

操作系统需要提供内存保护功能，保证各进程在各自存储空间内运行，互不干扰

**方法一：**&#x5728; CPU 中**设置一对上、下限寄存器**，存放进程的上、下限地址。进程的指令要访问某个地址时， CPU 检查是否越界

![](https://824295091-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MEmUhsvIFBb8ar2-Um3%2F-MFKZoz-Ajqc2X7ejgbl%2F-MFKrLNo117_SIR8WsI4%2Fimage.png?alt=media\&token=423c3fbf-928a-443b-9152-a1a6baf41be0)

**方法二：**&#x91C7;用**重定位寄存器（基质寄存器）**&#x548C;**界地址寄存器（限长寄存器）**&#x8FDB;行越界检查

* **重定位寄存器：**&#x5B58;放进程的起始物理位置
* **界地址寄存器：**&#x5B58;放进程的最大逻辑地址（进程的大小）

![](https://824295091-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MEmUhsvIFBb8ar2-Um3%2F-MFKs43LHUT-hwM_1trz%2F-MFKsJKVCZBorGN7TooO%2Fimage.png?alt=media\&token=00c92010-d932-4fae-9d36-1ea429288103)
