rust os comp's daily blog

Azathoth published on
5 min, 838 words

Categories: Blog

rust 好好好!

Intro

这里是我学习rust-based-os-comp的一个日常记录

我的个人实验环境配置:

sf

Blog

由于我看到训练营的通知较晚,导致我在最后一天才了解这个项目,又因为这几天还在学校实习,所以可能最近几天进度比较慢.

2022-07-05 (day 1)

Task / Progress

  • 配置本地rust环境(之前已经配好)
  • 尝试 gitclassroom, 使用 codespace 进行 rustlings 的训练
  • rustlings:
    • variables
    • functions
    • move_semantics

2022-07-06 (day 2)

Task / Progress

  • 第零章 实验环境配置
  • 第一章 应用程序与基本执行环境(lab0-0)
  • rustlings:
    • primitive_types
    • enums
    • structs

实验环境配置

第零章:实验环境配置

由于我之前接触过mit的 6.S081, qemu已经装好(mit 6.S081的安装指引)

通过命令:qemu-riscv64 -version, 可以看出qemu的版本.

此外, 我用的是manjaro(一个基于arch linux的linux发行版),所以qemu版本较新,符合实验要求.

根据文档,clone仓库, 运行

cd os1
LOG=DEBUG make run

成功获得输出:

test_run

QA / Thinking / Reading

  1. 为什么 rust 的 两个宏: print/pringln 不能被写进core而需要写进std

By default, all Rust crates link the standard library, which depends on the operating system for features such as threads, files, or networking. It also depends on the C standard library libc, which closely interacts with OS services. Since our plan is to write an operating system, we can not use any OS-dependent libraries. So we have to disable the automatic inclusion of the standard library through the no_std attribute.

为了打印到标准输出, 需要与内核进行交互, 因此必然与所在平台有关

  1. 为什么rust的core libarary能做到 platform-agnostic.

  2. Why does Rust have a "Never" primitive type?

  3. What is a real world example of using a unit struct?

2022-07-07 (day 3)

Task / Progress

  • 第二章 批处理系统: 看到最后一节
  • rustlings:
    • collections
    • error_handling
    • generics
    • modules
    • option
    • standard_library_types
    • strings
    • tests
    • threads
    • traits

QA / Thinking / Reading

  1. rfc of associated items
  2. git conventional commits

2022-07-08 (day 4)

rustlings终于写完了..

macros这部分的练习出的有点敷衍 😂

感觉要看懂rCore tutorial, 修改它的代码, 还得学点 unsafe rust, 只做 rustlings 和一些常规的练习感觉完全不够啊

Task / Progress

  • 看完第二章,开始看第三章(感觉汇编部分还是有点吃力,看来得好好学下riscv了)
  • 看了下 writing an OS in rust
  • 完成 rustlings complete_rustlings

QA / Thinking / Reading

  1. mut self and self
  2. writing an OS in rust

2022-07-09 (day 5)

今天不太想做lab...

Task / Progress

QA / Thinking / Reading

  1. writing an OS in rust
  2. The Rustonomicon

2022-07-10 (day 6)

今天好像没干啥...

Task / Progress

QA / Thinking / Reading

2022-07-11 (day 7)

2022-07-12 (day 8)

2022-07-13 (day 9)

2022-07-14 (day 10)

2022-07-15 (day 11)

2022-07-16 (day 12)

2022-07-17 (day 13)