Skip to content

Commit 0f3363a

Browse files
committed
Add online judge related content and modify some descriptions
1 parent 39595b3 commit 0f3363a

5 files changed

Lines changed: 90 additions & 11 deletions

File tree

src/content/docs/lab1/01-ownership-and-memory.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ import { Tabs, TabItem } from '@astrojs/starlight/components';
1111

1212
:::note
1313
学习 Rust 语言可以参考 [Rust Book](https://doc.rust-lang.org/book/) 或者 [Rust 语言圣经](https://course.rs/about-book.html). 官方文档为 [std - rust](https://doc.rust-lang.org/std/index.html)[core - rust](https://doc.rust-lang.org/core/index.html).
14-
15-
本章内容仅仅是作为对 Rust 重要语言特性的梳理,并不能直接代替对 Rust Book 或者 Rust 语言圣经的阅读. 你可以先大致阅读本章,然后通过 Rustlings 和提到的两本书来学习. 也可以在完成之后最后阅读本章.
1614
:::
1715

1816
:::tip
19-
我们建议跟着 [Rustlings](/ustb-os-tutorial/lab1/pratice/) 进行学习,如遇到不懂的地方,再查看文档进行对应内容.
17+
本章内容仅仅是作为对 Rust 重要语言特性的梳理,并不能直接代替对 Rust Book 或者 Rust 语言圣经的阅读.
18+
19+
我们建议阅读了本节所有权相关的内容后,跟着 [Rustlings](/ustb-os-tutorial/lab1/pratice/) 进行学习,尝试完成所有练习. 完成练习过程中,如遇到不懂的地方,再查看 Rust Book 或 Rust 语言圣经 进行对应的学习. 完成 Rustlings 后再阅读本章的剩下两小节.
2020
:::
2121

2222
本节将讲解 Rust 所有权 (ownership) 与内存布局 (memory layout).

src/content/docs/lab1/pratice.mdx

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,38 @@ title: 练习
33
description: lab1 rustlings 练习
44
---
55

6+
## 运行程序
7+
68
执行如下命令:
79

810
```shell
911
git clone https://github.com/Source-of-USTB/ustb-os-rustlings.git
1012
```
1113

14+
需要安装 Rust 环境,或者使用 Docker 镜像,将 `ustb-os-rustlings` 挂载.
15+
1216
进入项目目录后,再执行:
1317

1418
```shell
19+
# 注意 . 是当前目录
1520
cargo install --force --path .
1621
```
1722

1823
之后你可以执行 `rustlings watch` 命令来启动交互式界面,完成习题.
1924

2025
每完成一道习题,需要删除注释 `// I AM NOT DONE`,否则该题不会被标记为完成.
2126

22-
直至所有练习完成,提交希冀评测.
27+
直至所有练习完成,提交希冀评测.
28+
29+
## 提交评测
30+
31+
将项目打包为 `.tar.gz` 的格式.
32+
33+
```shell
34+
cd /path/to/ustb-os-rustlings
35+
tar -czf ../ustb-os-rustlings.tar.gz .
36+
```
37+
38+
将会在 rustlings 的**上级目录**生成一个 `ustb-os-rustlings.tar.gz` 文件,压缩包的内容是 rustlings 目录的文件.
39+
40+
然后提交 `.tar.gz` 文件到 CG 进行评测.

src/content/docs/lab2/01-simplest-kernel.mdx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ description: simplest OS kernel
55

66
从本章开始,我们将正式进入操作系统的实验部分. 在本章中,我们将分析实验源码,理清最小化 OS 内核和批处理系统的工作原理.
77

8+
拉取我们的实验代码:
9+
10+
```shell
11+
git clone https://github.com/USTB-806/ustb-os-kernel.git
12+
git checkout lab2
13+
```
14+
15+
如果你对于手册某些具体内容的实现感到疑惑,我们建议你可以通过阅读 commits 来查看我们的更改.
16+
817
## 极简的用户态执行环境
918

1019
一个基础的概念是,我们在学习操作系统的过程中会大量讨论内核态与用户态. 正如你在课上所学的,执行一个程序的时候,我们就在内核态与用户态之间不断进行上下文切换. 在完成实验的过程中我们会逐步加深对其的理解. 此处我们先讨论一个最简单的用户态程序.
@@ -131,7 +140,7 @@ fn main() {
131140
本次实验中,你只需要会阅读链接脚本和 RISC-V 汇编即可. 有更高需求的同学可以尝试自行修改.
132141
:::
133142

134-
回忆你在计科导学习的知识,我们可以通过 **链接脚本** (Linker Script) 调整链接器的行为,使得最终生成的输出文件的内存布局符合我们的预期. 我们需要这么做的原因是,平时我们都使用操作系统帮我们管理好的内存布局,所以大部分情况下我们不需要考虑 `.data`, `.text` 这些段是怎么排布的. 但我们在开发操作系统内核时就需要自己管理这些部分.
143+
回忆你在计算机系统基础学习的知识,我们可以通过 **链接脚本** (Linker Script) 调整链接器的行为,使得最终生成的输出文件的内存布局符合我们的预期. 我们需要这么做的原因是,平时我们都使用操作系统帮我们管理好的内存布局,所以大部分情况下我们不需要考虑 `.data`, `.text` 这些段是怎么排布的. 但我们在开发操作系统内核时就需要自己管理这些部分.
135144

136145
我们修改 Cargo 的配置文件来使用我们自己的链接脚本 `kernel/src/linker.ld` 而非使用默认的[内存布局](../02-function-and-memory/#程序内存布局).
137146

src/content/docs/lab2/practice.mdx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,14 @@ title: 练习
33
description: lab2 练习,硬编码 sys_write 和 C Lib 支持
44
---
55

6-
执行 `user/c/apps/read.c` 程序,尝试让其输出 `Read content: Success!`.
6+
首先克隆实验代码:
7+
8+
```shell
9+
git clone https://github.com/USTB-806/ustb-os-kernel.git
10+
git checkout lab2
11+
```
12+
13+
本章的练习是:成功执行 `user/c/apps/read.c` 程序,尝试让其输出 `Read content: Success!`.
714

815
你可能注意到了 commit 记录里 `user/c/lib/lib.h` 的添加:
916

@@ -21,14 +28,14 @@ isize read(int fd, void *buf, size_t count);
2128
2229
除此之外,你可以关注 `kernel/src/syscall/fs.rs` 这个文件,这是文件相关 syscalls 被定义处,尝试修改 syscalls 让 `read.c` 正常输出.
2330
24-
另外,如果想要运行本地测试,而不是重复云端评测,可以
31+
另外,我们建议通过本地测试后,再提交至云端进行评测,你可以通过 `stdout-ch2` 看到测评的整个流程. 执行
2532
26-
```
33+
```shell
2734
cd ustb-os-kernel
2835
git clone https://github.com/USTB-806/ustb-os-checker.git
2936
3037
cd ustb-os-checker
31-
python3 test_runner.py 2
38+
make test CHAPTER=2
3239
```
3340

34-
意为运行第 2 章的测试.
41+
其中 `CHAPTER=2` 意为运行第 2 章的测试.

src/content/docs/preface/judge.mdx

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,49 @@ description: 如何评测
44
template: doc
55
---
66

7-
TODO
7+
由于学校评测系统的限制,我们需要通过上传 `.tar.gz` 压缩包的方式进行评测.
8+
9+
建议先在本地执行评测,然后再上传至 CG 系统.
10+
11+
:::note
12+
若遇到任何评测机 RE 或者本地评测与云端不一致的情况,请联系助教进行修复.
13+
:::
14+
15+
## Lab1 评测
16+
17+
评测内容为执行 `rustlings verify`,根据通过 case 的数量进行计分.
18+
19+
若使用云端评测,需将项目打包为 `.tar.gz` 的格式.
20+
21+
```shell
22+
cd /path/to/ustb-os-rustlings
23+
tar -czf ../ustb-os-rustlings.tar.gz .
24+
```
25+
26+
将会在 rustlings 的**上级目录**生成一个 `ustb-os-rustlings.tar.gz` 文件,压缩包的内容是 rustlings 目录的文件.
27+
28+
然后提交 `.tar.gz` 文件到 CG 进行评测.
29+
30+
## Lab2~6 评测
31+
32+
进入项目后,拉取测评机至与 `kernel``user` 同等目录的层级,然后执行 `make test`.
33+
34+
具体而言执行如下语句,以执行 lab3 的测试为例:
35+
36+
```shell
37+
cd /ustb-os-kernel
38+
git clone https://github.com/USTB-806/ustb-os-checker.git
39+
cd ustb-os-checker
40+
make test CHAPTER=3
41+
```
42+
43+
其中运行结果将保存至 `stdout-ch3` 文件中.
44+
45+
云端评测需要打包 `ustb-os-kernel`,执行:
46+
47+
```shell
48+
cd ustb-os-kernel
49+
tar -czf ../submit.tar.gz --exclude='./ustb-os-checker' --exclude='./*/target' --exclude='./.git' .
50+
```
51+
52+
然后将上级目录生成的 `submit.tar.gz` 上传至 CG.

0 commit comments

Comments
 (0)