Skip to content

Commit 7f8d19e

Browse files
fix typo 'port' -> 'prot' (#161)
1 parent 32ca9ba commit 7f8d19e

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

source/chapter4/8exercise.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,21 +69,21 @@ mmap 和 munmap 匿名映射
6969

7070
.. code-block:: rust
7171
72-
fn sys_mmap(start: usize, len: usize, port: usize) -> isize
72+
fn sys_mmap(start: usize, len: usize, prot: usize) -> isize
7373
7474
- syscall ID:222
75-
- 申请长度为 len 字节的物理内存(不要求实际物理内存位置,可以随便找一块),将其映射到 start 开始的虚存,内存页属性为 port
75+
- 申请长度为 len 字节的物理内存(不要求实际物理内存位置,可以随便找一块),将其映射到 start 开始的虚存,内存页属性为 prot
7676
- 参数:
7777
- start 需要映射的虚存起始地址,要求按页对齐
7878
- len 映射字节长度,可以为 0
79-
- port:第 0 位表示是否可读,第 1 位表示是否可写,第 2 位表示是否可执行。其他位无效且必须为 0
79+
- prot:第 0 位表示是否可读,第 1 位表示是否可写,第 2 位表示是否可执行。其他位无效且必须为 0
8080
- 返回值:执行成功则返回 0,错误返回 -1
8181
- 说明:
8282
- 为了简单,目标虚存区间要求按页对齐,len 可直接按页向上取整,不考虑分配失败时的页回收。
8383
- 可能的错误:
8484
- start 没有按页大小对齐
85-
- port & !0x7 != 0 (port 其余位必须为0)
86-
- port & 0x7 = 0 (这样的内存无意义)
85+
- prot & !0x7 != 0 (prot 其余位必须为0)
86+
- prot & 0x7 = 0 (这样的内存无意义)
8787
- [start, start + len) 中存在已经被映射的页
8888
- 物理内存不足
8989

@@ -102,7 +102,7 @@ munmap 定义如下:
102102
- [start, start + len) 中存在未被映射的虚存。
103103

104104

105-
TIPS:注意 port 参数的语义,它与内核定义的 MapPermission 有明显不同!
105+
TIPS:注意 prot 参数的语义,它与内核定义的 MapPermission 有明显不同!
106106

107107
实验要求
108108
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

source/chapter4/9answer.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,21 +141,21 @@ mmap 和 munmap 匿名映射
141141

142142
.. code-block:: rust
143143
144-
fn sys_mmap(start: usize, len: usize, port: usize) -> isize
144+
fn sys_mmap(start: usize, len: usize, prot: usize) -> isize
145145
146146
- syscall ID:222
147-
- 申请长度为 len 字节的物理内存(不要求实际物理内存位置,可以随便找一块),将其映射到 start 开始的虚存,内存页属性为 port
147+
- 申请长度为 len 字节的物理内存(不要求实际物理内存位置,可以随便找一块),将其映射到 start 开始的虚存,内存页属性为 prot
148148
- 参数:
149149
- start 需要映射的虚存起始地址,要求按页对齐
150150
- len 映射字节长度,可以为 0
151-
- port:第 0 位表示是否可读,第 1 位表示是否可写,第 2 位表示是否可执行。其他位无效且必须为 0
151+
- prot:第 0 位表示是否可读,第 1 位表示是否可写,第 2 位表示是否可执行。其他位无效且必须为 0
152152
- 返回值:执行成功则返回 0,错误返回 -1
153153
- 说明:
154154
- 为了简单,目标虚存区间要求按页对齐,len 可直接按页向上取整,不考虑分配失败时的页回收。
155155
- 可能的错误:
156156
- start 没有按页大小对齐
157-
- port & !0x7 != 0 (port 其余位必须为0)
158-
- port & 0x7 = 0 (这样的内存无意义)
157+
- prot & !0x7 != 0 (prot 其余位必须为0)
158+
- prot & 0x7 = 0 (这样的内存无意义)
159159
- [start, start + len) 中存在已经被映射的页
160160
- 物理内存不足
161161

@@ -174,7 +174,7 @@ munmap 定义如下:
174174
- [start, start + len) 中存在未被映射的虚存。
175175

176176

177-
TIPS:注意 port 参数的语义,它与内核定义的 MapPermission 有明显不同!
177+
TIPS:注意 prot 参数的语义,它与内核定义的 MapPermission 有明显不同!
178178

179179
实验要求
180180
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)