os_kernel_lab
os_kernel_lab copied to clipboard
OS kernel labs based on Rust/C Lang & RISC-V 64/X86-32
To save a few clicks. The translation is good enough to follow and likely preferred until the Chinese version is almost complete.
This is the output of `make` ``` make[1]: Entering directory '/home/lin/workspace/clone/os_kernel_lab/user' Installing rcore-fs-fuse Updating git repository `https://github.com/rcore-os/rcore-fs` Installing rcore-fs-fuse v0.1.0 (https://github.com/rcore-os/rcore-fs#6df6cd24) Updating crates.io index Compiling libc v0.2.101 Compiling log v0.4.14...
zhu@ubuntu:~/qemu-4.2.0/rCore-Tutorial$ sudo make make[1]: 进入目录“/home/zhu/qemu-4.2.0/rCore-Tutorial/user” Installing rcore-fs-fuse Updating git repository `https://github.com/rcore-os/rcore-fs` Installing rcore-fs-fuse v0.1.0 (https://github.com/rcore-os/rcore-fs#6df6cd24) Updating crates.io index Compiling libc v0.2.79 Compiling log v0.4.11 Compiling winapi-build v0.1.1 Compiling cfg-if v0.1.10...
## What - Added the `handle_interrupt` function to `interrupt.asm` in part4 - Added `Scause` to `handler.rs` in part 5
感觉老师或同学能适当堆内联汇编部分的输入输出操作数增加一点解释,目前的版本略有点晦涩,解释的语句很多专有名词,较为抽象。如果能将这些操作数存在的原因稍作解释就好理解很多
我是外校的学生,为了上手方便我仍然使用贵校开发的基于c语言实现的uCore进行练习。我不是很清楚贵校开发团队是否还在维护这个项目的c语言版本,也不了解贵校开发团队的rCore是否也存在类似的问题,**如有打扰还请谅解**! 以下是我个人给出的临时修复办法: *** uCore官方实现的提供给用户程序使用的`cprintf`函数实现是非原子的。这会导致什么问题呢? 举个例子,假设有两个进程A和B,如果进程A想打印字符串"Hello World",进程B想打印字符串"Thanks for You",则可能最终会在设备屏幕上输出"Hello Thanks for World"或者其他的混乱结果。这显然会影响我们正常开展本次实验,以及导致无法使用`make grade`对我们的代码进行评测! 这是因为uCore中用户进程每打印一个ASCII字符,都需要请求一次`SYS_putc`系统调用,因此虽然每次系统调用的执行是原子的,但这个用户程序在逐个打印字符的过程中仍然可能会被时钟中断,转而执行其他进程,从而导致屏幕输出结果的混乱。 这里我采用最简单粗暴的办法来修复这个bug,即直接给`cprintf`函数上一把大锁。 首先,由于lab6中uCore还没有实现锁机制,我们需要**在内核代码中**自行封装一个自旋锁。 代码如下,其中原子操作`__sync_lock_test_and_set`和`__sync_lock_release`由gcc编译器提供,我们无需关心其具体实现: ```C++ // kern/sync/my_spin_lock.h // 这个结构体用于表示自旋锁 typedef struct { volatile int locked; } spinlock_t; void...