Skip to content

Commit

Permalink
Lab 7: 更好的内存管理 (#35)
Browse files Browse the repository at this point in the history
Co-authored-by: henry-y <[email protected]>
Co-authored-by: Smallorange666 <[email protected]>
  • Loading branch information
3 people authored Jun 5, 2024
1 parent 9ede679 commit 81df9d9
Show file tree
Hide file tree
Showing 60 changed files with 2,829 additions and 1,146 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ name: Deploy on GitHub Pages
on:
workflow_dispatch:
push:
branches: ["main", "lab/*"]
paths: ["docs/**"]
branches: ['main', 'lab/*']
paths: ['docs/**']

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: "pages"
group: 'pages'
cancel-in-progress: false

jobs:
Expand Down
14 changes: 14 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"trailingComma": "es5",
"tabWidth": 2,
"semi": false,
"singleQuote": true,
"overrides": [
{
"files": "*.md",
"options": {
"tabWidth": 4
}
}
]
}
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

## 实验反馈

- 交流实验中遇到的困难:[![Discussions](https://img.shields.io/github/discussions/YatSenOS/YatSenOS-Tutorial-Volume-2)](https://github.com/YatSenOS/YatSenOS-Tutorial-Volume-2/discussions)
- 提出实验设计的问题:[![Issues](https://img.shields.io/github/issues/YatSenOS/YatSenOS-Tutorial-Volume-2)](https://github.com/YatSenOS/YatSenOS-Tutorial-Volume-2/issues)
- 改善这个实验:[![Issues-pr](https://img.shields.io/github/issues-pr/YatSenOS/YatSenOS-Tutorial-Volume-2)](https://github.com/YatSenOS/YatSenOS-Tutorial-Volume-2/pulls)
- 交流实验中遇到的困难:[![Discussions](https://img.shields.io/github/discussions/YatSenOS/YatSenOS-Tutorial-Volume-2)](https://github.com/YatSenOS/YatSenOS-Tutorial-Volume-2/discussions)
- 提出实验设计的问题:[![Issues](https://img.shields.io/github/issues/YatSenOS/YatSenOS-Tutorial-Volume-2)](https://github.com/YatSenOS/YatSenOS-Tutorial-Volume-2/issues)
- 改善这个实验:[![Issues-pr](https://img.shields.io/github/issues-pr/YatSenOS/YatSenOS-Tutorial-Volume-2)](https://github.com/YatSenOS/YatSenOS-Tutorial-Volume-2/pulls)

## 常见问题解答

Expand Down
23 changes: 12 additions & 11 deletions docs/css/extra.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
}

h5 {
font-size: .75rem;
font-size: 0.75rem;
}

h6 {
font-size: .7rem;
font-size: 0.7rem;
}

details,
Expand Down Expand Up @@ -54,22 +54,22 @@ h2:before {
}
h3:before {
counter-increment: h3;
content: counter(h2) "." counter(h3);
content: counter(h2) '.' counter(h3);
margin-right: 0.8rem;
}
h4:before {
counter-increment: h4;
content: counter(h2) "." counter(h3) "." counter(h4);
content: counter(h2) '.' counter(h3) '.' counter(h4);
margin-right: 0.8rem;
}
h5:before {
counter-increment: h5;
content: counter(h2) "." counter(h3) "." counter(h4) "." counter(h5);
content: counter(h2) '.' counter(h3) '.' counter(h4) '.' counter(h5);
margin-right: 0.8rem;
}
h6:before {
counter-increment: h6;
content: counter(h2) "." counter(h3) "." counter(h4) "." counter(h5) "."
content: counter(h2) '.' counter(h3) '.' counter(h4) '.' counter(h5) '.'
counter(h6);
margin-right: 0.8rem;
}
Expand All @@ -84,20 +84,21 @@ table.wikitable {
color: var(--md-default-fg-color);
}

.wikitable th,.wikitable td {
.wikitable th,
.wikitable td {
border: 1px #aaa solid;
padding: 0.2em
padding: 0.2em;
}

.wikitable th {
background-color: var(--md-code-bg-color);
text-align: center
text-align: center;
}

.wikitable caption {
font-weight: bold;
}

[data-md-color-scheme="default"] .transparent-img {
filter: invert(1) hue-rotate(180deg)
[data-md-color-scheme='default'] .transparent-img {
filter: invert(1) hue-rotate(180deg);
}
24 changes: 12 additions & 12 deletions docs/css/fonts.css
Original file line number Diff line number Diff line change
@@ -1,53 +1,53 @@
@font-face {
font-family: "JetBrains Mono";
font-family: 'JetBrains Mono';
font-style: normal;
font-weight: 400;
font-display: swap;
src: url(../fonts/ecefdeb1.woff2) format("woff2");
src: url(../fonts/ecefdeb1.woff2) format('woff2');
unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F,
U+FE2E-FE2F;
}
@font-face {
font-family: "JetBrains Mono";
font-family: 'JetBrains Mono';
font-style: normal;
font-weight: 400;
font-display: swap;
src: url(../fonts/9f48e746.woff2) format("woff2");
src: url(../fonts/9f48e746.woff2) format('woff2');
unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
font-family: "JetBrains Mono";
font-family: 'JetBrains Mono';
font-style: normal;
font-weight: 400;
font-display: swap;
src: url(../fonts/4e44607d.woff2) format("woff2");
src: url(../fonts/4e44607d.woff2) format('woff2');
unicode-range: U+0370-03FF;
}
@font-face {
font-family: "JetBrains Mono";
font-family: 'JetBrains Mono';
font-style: normal;
font-weight: 400;
font-display: swap;
src: url(../fonts/4c204432.woff2) format("woff2");
src: url(../fonts/4c204432.woff2) format('woff2');
unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1,
U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329,
U+1EA0-1EF9, U+20AB;
}
@font-face {
font-family: "JetBrains Mono";
font-family: 'JetBrains Mono';
font-style: normal;
font-weight: 400;
font-display: swap;
src: url(../fonts/a6e389bf.woff2) format("woff2");
src: url(../fonts/a6e389bf.woff2) format('woff2');
unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF,
U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
font-family: "JetBrains Mono";
font-family: 'JetBrains Mono';
font-style: normal;
font-weight: 400;
font-display: swap;
src: url(../fonts/7c53386f.woff2) format("woff2");
src: url(../fonts/7c53386f.woff2) format('woff2');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191,
U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
Expand Down
1 change: 0 additions & 1 deletion docs/general/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ THU 的 rCore 课程实验是一个非常优秀的操作系统课程设计,它

> 如果需要进行多架构支持,需要对页表、寄存器、控制等内容进行抽象和统一,这部分的工程化抽象开销会很大的增加学生的学习成本。

### 为什么选择基于 UEFI 而不是自己使用汇编编写 bootloader?

汇编是一种非常底层的语言,对于大部分同学的学习经历来说,只在组成原理课程上接触过简单的 MIPS / RISC-V,而 x86 / ARM 基本接触很少。根据以往的经验,汇编的调试、编写、理解对于同学们都是很大的挑战。
Expand Down
18 changes: 9 additions & 9 deletions docs/general/help.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,18 @@ no_comments: true

提问时需要避免 X-Y 问题:即你实际遇到了 X 问题,你认为 X 问题要用 Y 方法解决,在实现 Y 方法时遇到困难,然后向他人提问如何实现 Y 方法。但很多时候 Y 方法并不是 X 问题的正确解法,此时可能会得到错误的答案。引用 [X-Y Problem](https://xyproblem.info/) 的一个例子:

- X 问题:想要截取文件名的后缀名
- Y 方法:截取文件名的后三位字符
- 此时的 Y 方法并不是解决 X 问题的正确方法,因为后缀名不一定是三个字符
- 正确的 X 问题的解法是找到最后一个 `.`,然后提取它之后的字符
- 如果提问的时候只提及了 Y 方法,而没有 X 问题,就会出现这样的问题
- X 问题:想要截取文件名的后缀名
- Y 方法:截取文件名的后三位字符
- 此时的 Y 方法并不是解决 X 问题的正确方法,因为后缀名不一定是三个字符
- 正确的 X 问题的解法是找到最后一个 `.`,然后提取它之后的字符
- 如果提问的时候只提及了 Y 方法,而没有 X 问题,就会出现这样的问题

因此在提问时,为了避免 X-Y 问题,建议按照下面的模板来描述完整的问题:

- 我正在做 X 问题
- 我认为为了解决 X 问题,可以用 Y 方法
- 在解决 X 问题时,采用了 Y 方法,过程中遇到了 Z 问题,尝试用 A 方法解决,但是没有效果
- 我正在做 X 问题
- 我认为为了解决 X 问题,可以用 Y 方法
- 在解决 X 问题时,采用了 Y 方法,过程中遇到了 Z 问题,尝试用 A 方法解决,但是没有效果

而不是:

- 我遇到了 Z 问题,求救 T_T
- 我遇到了 Z 问题,求救 T_T
24 changes: 12 additions & 12 deletions docs/general/specification.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,28 +46,28 @@ no_comments: true

建议使用工具来辅助代码风格的检查:

- 使用 `rustfmt``cargo fmt --all` 命令来格式化代码;
- 使用 `clippy``cargo clippy` 来检查代码风格。
- 使用 [typos](https://github.com/crate-ci/typos) 检查拼写错误,可以使用 `cargo install typos-cli` 安装。
- 使用 `rustfmt``cargo fmt --all` 命令来格式化代码;
- 使用 `clippy``cargo clippy` 来检查代码风格。
- 使用 [typos](https://github.com/crate-ci/typos) 检查拼写错误,可以使用 `cargo install typos-cli` 安装。

!!! note "请注意,由于项目 target 不尽相同,`clippy` 需要在每一个 `package` 下使用。"

## Git 相关

### 提交历史

- 每个提交都应该有一定的意义,例如实现了新功能,修复了一个问题,定义了新的函数;
- 比较复杂的程序,要边开发边提交,而不是写完了再一次性提交;
- 不强求线性历史,**但是不允许使用 force push**
- 每个提交都应该有一定的意义,例如实现了新功能,修复了一个问题,定义了新的函数;
- 比较复杂的程序,要边开发边提交,而不是写完了再一次性提交;
- 不强求线性历史,**但是不允许使用 force push**

### 提交消息

- 简单明了地描述这个提交的内容;
- 建议用英文写,用中文写也可以;
- 不要编写的过于详细或过于简略;
- 可以采用一些格式,例如 [**Conventional Commits**](https://www.conventionalcommits.org/en/v1.0.0/#examples)
- 不掺杂个人情绪;
- 可以添加一些 Emoji,[gitmoji](https://gitmoji.dev/) 为提交说明中使用的 Emoji 提出了一些建议,可以参考。
- 简单明了地描述这个提交的内容;
- 建议用英文写,用中文写也可以;
- 不要编写的过于详细或过于简略;
- 可以采用一些格式,例如 [**Conventional Commits**](https://www.conventionalcommits.org/en/v1.0.0/#examples)
- 不掺杂个人情绪;
- 可以添加一些 Emoji,[gitmoji](https://gitmoji.dev/) 为提交说明中使用的 Emoji 提出了一些建议,可以参考。

### 代码打包

Expand Down
17 changes: 9 additions & 8 deletions docs/general/typst.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# 使用 typst 编写实验报告

[typst](https://github.com/typst/typst) 是一个新型的基于标记的轻量化排版系统,相较于安装复杂且体积庞大的 LaTex,typst 所需要的空间仅仅约 30M,安装方法也十分简单,下载对应的二进制文件,添加到系统路径即可。对于IDE,推荐使用 VSCode,并安装 Typst LSP 插件实现实时预览。
[typst](https://github.com/typst/typst) 是一个新型的基于标记的轻量化排版系统,相较于安装复杂且体积庞大的 LaTex,typst 所需要的空间仅仅约 30M,安装方法也十分简单,下载对应的二进制文件,添加到系统路径即可。对于 IDE,推荐使用 VSCode,并安装 Typst LSP 插件实现实时预览。

关于 typst 的一些细节可以参考 [typst doc](https://typst.app/docs/),同时,推荐使用模板来撰写格式更加更为统一的实验报告,可以参考[模板](https://github.com/GZTimeWalker/GZ-Typst-Templates),后文给出了一个可能的使用方法。
关于 typst 的一些细节可以参考 [typst doc](https://typst.app/docs/),同时,推荐使用模板来撰写格式更加更为统一的实验报告,可以参考[模板](https://github.com/YatSenOS/YatSenOS-Tutorial-Volume-2/tree/main/template),后文给出了一个可能的使用方法。

## 使用示例

Expand All @@ -12,11 +12,13 @@

为了方便,我们从头开始,新建一个文件夹,专门用来进行实验报告的撰写。

假设你本地已经克隆了一份[模板](https://github.com/GZTimeWalker/GZ-Typst-Templates),在 Unix 系统中使用 `ln -s /path/to/the/template/repo base` 创建一个名为 `base` 的软链接,目的是为了方便我们后续使用模板。操作成功后,你的目录结构应该类似于:
本实验报告模板存放在本实验仓库的 `templates` 目录下,你可以通过 `git clone` 或者直接下载的方式将其下载到本地。

假设你本地已经克隆了一份模版,在 Unix 系统中使用 `ln -s /path/to/the/template/repo base` 创建一个名为 `base` 的软链接,目的是为了方便我们后续使用模板。操作成功后,你的目录结构应该类似于:

```txt
.
└── base -> ../GZ-Typst-Templates
└── base -> ../template
```

!!! tip "对于 Windows 用户,可以考虑使用 mklink 来创建软链接,或直接拷贝模版文件"
Expand All @@ -25,7 +27,7 @@

```txt
.
├── base -> ../GZ-Typst-Templates
├── base -> ../template
└── lab-0
├── images
│   └── linux.png
Expand All @@ -34,7 +36,6 @@

之后,在当前文件夹中打开终端或使用 VSCode,正常使用 typst 即可,例如:


!!! note "保证 typst 的工作路径为 `.`"

引用其他更上层的目录是被 Typst 默认禁止的,这是为了避免[任意文件读取](https://github.com/typst/typst/issues/219)问题。
Expand All @@ -44,7 +45,7 @@
打开 `example.typ`,并输入:

```js
#import "../base/templates/report.typ": *
#import "../base/report.typ": *

#show: report.with(
title: "实验报告实验",
Expand Down Expand Up @@ -165,4 +166,4 @@ $ sum_(k=1)^n k = (n(n+1)) / 2 $

会被渲染成单独的一行:

$$ \sum_{k=1}^n k = \frac{n(n+1)}{2} $$
$$ \sum\_{k=1}^n k = \frac{n(n+1)}{2} $$
18 changes: 9 additions & 9 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@

每一次实验区间为两周。

- [实验零:环境搭建与实验准备](./labs/0x00/index.md)
- [实验一:操作系统的启动](./labs/0x01/index.md)
- [实验二:中断处理](./labs/0x02/index.md)
- [实验三:内核线程与缺页异常](./labs/0x03/index.md)
- [实验四:用户程序与系统调用](./labs/0x04/index.md)
- [实验五:fork 的实现、并发与锁机制](./labs/0x05/index.md)
- [实验六:硬盘驱动与文件系统](./labs/0x06/index.md)
- [实验七:更好的内存管理](./labs/0x07/index.md)
- [实验八:扩展实验](./labs/0x08/index.md)
- [实验零:环境搭建与实验准备](./labs/0x00/index.md)
- [实验一:操作系统的启动](./labs/0x01/index.md)
- [实验二:中断处理](./labs/0x02/index.md)
- [实验三:内核线程与缺页异常](./labs/0x03/index.md)
- [实验四:用户程序与系统调用](./labs/0x04/index.md)
- [实验五:fork 的实现、并发与锁机制](./labs/0x05/index.md)
- [实验六:硬盘驱动与文件系统](./labs/0x06/index.md)
- [实验七:更好的内存管理](./labs/0x07/index.md)
- [实验八:扩展实验](./labs/0x08/index.md)
12 changes: 6 additions & 6 deletions docs/labs/0x00/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@

对于本次实验内容,你需要参考学习如下实验资料:

- [Linux 环境配置](../../wiki/linux.md)
- [Windows 环境配置](../../wiki/windows.md)
- [Rust 语言学习](../../wiki/rust.md)
- [UEFI 启动过程](../../wiki/uefi.md)
- [QEMU 使用参考](../../wiki/qemu.md)
- [Linux 环境配置](../../wiki/linux.md)
- [Windows 环境配置](../../wiki/windows.md)
- [Rust 语言学习](../../wiki/rust.md)
- [UEFI 启动过程](../../wiki/uefi.md)
- [QEMU 使用参考](../../wiki/qemu.md)

## 实验任务与要求

Expand All @@ -37,7 +37,7 @@
3. 依据 [实验任务](./tasks.md) 完成实验。

- 代码编写任务:观察提供的代码,完善所有标记为 `FIXME:` 的部分,并验证结果是否符合预期。**请在报告中介绍实现思路,截图展示关键结果。**
- 思考任务:完成 “思考题” 和 “实验任务” 部分的内容,**在报告中简要进行回答***:思考题可能也是理解代码、实现功能的重要提示。*
- 思考任务:完成 “思考题” 和 “实验任务” 部分的内容,**在报告中简要进行回答**_:思考题可能也是理解代码、实现功能的重要提示。_
- Bonus 加分项:学有余力的同学可以任选 Bonus 部分完成,尝试完成更多的功能,并在报告中进行展示。这部分内容不是必须的要求。

4. 请在实验报告中涵盖相关任务的实现截图、实验任务对应问题的解答、实验过程中遇到的问题与解决方案等内容。
Loading

0 comments on commit 81df9d9

Please sign in to comment.