From c66976a031eca7554a40541017b871243452d160 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9E=97=E4=BC=9F?= Date: Wed, 16 Oct 2024 14:51:18 +0800 Subject: [PATCH 1/3] Update 6multitasking-based-on-as.rst --- source/chapter4/6multitasking-based-on-as.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/chapter4/6multitasking-based-on-as.rst b/source/chapter4/6multitasking-based-on-as.rst index a160cbab8..b78996f76 100644 --- a/source/chapter4/6multitasking-based-on-as.rst +++ b/source/chapter4/6multitasking-based-on-as.rst @@ -60,7 +60,7 @@ 可以看到,我们最先进行了全局动态内存分配器的初始化,因为接下来马上就要用到 Rust 的堆数据结构。接下来我们初始化物理页帧管理器(内含堆数据结构 ``Vec`` )使能可用物理页帧的分配和回收能力。最后我们创建内核地址空间并让 CPU 开启分页模式, MMU 在地址转换的时候使用内核的多级页表,这一切均在一行之内做到: -- 首先,我们引用 ``KERNEL_SPACE`` ,这是它第一次被使用,就在此时它会被初始化,调用 ``MemorySet::new_kernel`` 创建一个内核地址空间并使用 ``Arc>`` 包裹起来; +- 首先,我们引用 ``KERNEL_SPACE`` ,这是它第一次被使用,就在此时它会被初始化,调用 ``MemorySet::new_kernel`` 创建一个内核地址空间并使用 ``Arc>`` 包裹起来; - 接着使用 ``.exclusive_access()`` 获取一个可变引用 ``&mut MemorySet`` 。需要注意的是这里发生了两次隐式类型转换: 1. 我们知道 ``exclusive_access`` 是 ``UPSafeCell`` 的方法而不是 ``Arc`` 的方法,由于 ``Arc`` 实现了 ``Deref`` Trait ,当 ``exclusive_access`` 需要一个 ``&UPSafeCell`` 类型的参数的时候,编译器会自动将传入的 ``Arc>`` 转换为 ``&UPSafeCell`` 这样就实现了类型匹配; From 93c1a63d15356c8e6e5d26c7dac7dad4ec20dfdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9E=97=E4=BC=9F?= Date: Wed, 16 Oct 2024 14:59:04 +0800 Subject: [PATCH 2/3] Update 6multitasking-based-on-as.rst --- source/chapter4/6multitasking-based-on-as.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/chapter4/6multitasking-based-on-as.rst b/source/chapter4/6multitasking-based-on-as.rst index b78996f76..408edb291 100644 --- a/source/chapter4/6multitasking-based-on-as.rst +++ b/source/chapter4/6multitasking-based-on-as.rst @@ -83,7 +83,7 @@ let satp = self.page_table.token(); unsafe { satp::write(satp); - asm!("sfence.vma" :::: "volatile"); + asm!("sfence.vma"); } } } From 7d9a743501368465f1ad733879a42db235fdb6ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9E=97=E4=BC=9F?= Date: Wed, 16 Oct 2024 15:09:40 +0800 Subject: [PATCH 3/3] Update 6multitasking-based-on-as.rst --- source/chapter4/6multitasking-based-on-as.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/chapter4/6multitasking-based-on-as.rst b/source/chapter4/6multitasking-based-on-as.rst index 408edb291..486afc21e 100644 --- a/source/chapter4/6multitasking-based-on-as.rst +++ b/source/chapter4/6multitasking-based-on-as.rst @@ -119,7 +119,7 @@ // os/src/mm/memory_set.rs pub fn remap_test() { - let mut kernel_space = KERNEL_SPACE.lock(); + let mut kernel_space = KERNEL_SPACE.exclusive_access(); let mid_text: VirtAddr = ((stext as usize + etext as usize) / 2).into(); let mid_rodata: VirtAddr = ((srodata as usize + erodata as usize) / 2).into(); let mid_data: VirtAddr = ((sdata as usize + edata as usize) / 2).into();