├── .github ├── .keep └── workflows │ └── classroom.yml └── README.md /.github/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LearningOS/oscomp-kernel-training/69117cba232ebec146cfd56280abede69c4d9ff6/.github/.keep -------------------------------------------------------------------------------- /.github/workflows/classroom.yml: -------------------------------------------------------------------------------- 1 | name: GitHub Classroom Workflow 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | paths-ignore: 8 | - 'README.md' 9 | - '.github/**' 10 | 11 | env: 12 | IMG_URL: https://github.com/os-autograding/testsuits-in-one/raw/gh-pages/fat32.img # 镜像url 13 | TIMEOUT: 480 # QEMU超时时间设置为8分钟 14 | SCRIPT_REPO: https://github.com/os-autograding/EvaluationScript # 脚本仓库 15 | TZ: Asia/Shanghai # 设置时区 16 | 17 | jobs: 18 | build: 19 | name: Autograding 20 | runs-on: ubuntu-latest 21 | outputs: 22 | details: ${{ steps.autograding.outputs.details }} 23 | points: ${{ steps.autograding.outputs.points}} 24 | steps: 25 | - uses: actions/checkout@v3 26 | - uses: actions-rs/toolchain@v1 27 | with: 28 | profile: minimal 29 | toolchain: nightly-2022-08-08 30 | components: rust-src, llvm-tools-preview 31 | target: riscv64imac-unknown-none-elf 32 | override: true 33 | - uses: baptiste0928/cargo-install@v1 34 | with: 35 | crate: cargo-binutils 36 | cache-key: cargo-binutils 37 | - name: Cache QEMU 38 | id: qemu 39 | uses: actions/cache@v3 40 | with: 41 | path: qemu-7.0.0 42 | key: qemu-7.0.0-x86_64-riscv64 43 | - name: Compile QEMU 44 | if: steps.qemu.outputs.cache-hit != 'true' 45 | run: | 46 | sudo apt-get update 47 | sudo apt-get install ninja-build -y 48 | wget https://download.qemu.org/qemu-7.0.0.tar.xz 49 | tar -xf qemu-7.0.0.tar.xz 50 | cd qemu-7.0.0 51 | ./configure --target-list=riscv64-softmmu 52 | make -j 53 | - name: Install QEMU 54 | run: | 55 | sudo apt-get update 56 | sudo apt-get install ninja-build -y 57 | cd qemu-7.0.0 58 | sudo make install 59 | qemu-system-riscv64 --version 60 | - name: build os.bin 61 | run: | 62 | make all 63 | - name: run os 64 | run: | 65 | wget $IMG_URL -O fat32.img 66 | timeout $TIMEOUT qemu-system-riscv64 \ 67 | -machine virt \ 68 | -bios default \ 69 | -device loader,file=kernel-qemu,addr=0x80200000 \ 70 | -drive file=fat32.img,if=none,format=raw,id=x0 \ 71 | -device virtio-blk-device,drive=x0,bus=virtio-mmio-bus.0 \ 72 | -kernel kernel-qemu \ 73 | -nographic \ 74 | -smp 4 -m 2G | tee qemu_run_output.txt 75 | - name: Download Scripts 76 | run: | 77 | git clone $SCRIPT_REPO .github/classroom 78 | - uses: yfblock/os-autograding@master 79 | id: autograding 80 | with: 81 | outputFile: qemu_run_output.txt 82 | deploy: 83 | name: Deploy to pages 84 | needs: build 85 | runs-on: ubuntu-latest 86 | steps: 87 | - uses: actions/checkout@v3 88 | - name: Test Autograding Output 89 | run: | 90 | echo "${{ needs.build.outputs.details }}" 91 | - run: | 92 | mkdir autograding_logs 93 | cd autograding_logs 94 | echo -ne "${{ needs.build.outputs.details }}\nPoints: ${{ needs.build.outputs.points }}" \ 95 | >> `date +%Y_%m_%d_%H_%M_%S`.txt 96 | 97 | - name: GitHub Pages 98 | uses: crazy-max/ghaction-github-pages@v3 99 | with: 100 | target_branch: gh-pages 101 | build_dir: autograding_logs 102 | keep_history: true 103 | env: 104 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 105 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # oscomp kernel training 2 | **2022年开源操作系统训练营:第二阶段** 3 | 4 | ## 训练邀请:OS kernel设计与实现 5 | - [点击:创建自己的内核赛道训练repo](https://classroom.github.com/a/vk-D9SrL) 6 | - [查看训练排行榜单](https://os-autograding.github.io/classroom-grading-template/) 7 | 8 | **注:** 9 | 1. **基于Github Classroom,具有在线编程,在线自动评测,在线显示排行榜的特征** 10 | 2. **基于2022全国大学生OS比赛内核赛道,训练内容和难度超过全球99.9%的大学本科OS实验** 11 | 3. **没学过git/github使用、C/Rust语言、基本数据结构和算法、操作系统和与RISC-V相关的组成原理课程的同学,建议先补一下相关知识** 12 | 13 | ## 内核赛道OS训练repo说明 14 | 15 | > 目前支持对2022全国大学生OS比赛内核赛道的Linux Apps测例的测试,采用形式与比赛大致相同,选手需要在根目录添加一个 Makefile 文件,使用 make all 命令在根目录生成 kernel-qemu 文件,由评测机自动执行。 16 | 17 | - 一个基本的能运行的 `kernel demo`: [https://github.com/yfblock/oscomp-kernel-example](https://github.com/yfblock/oscomp-kernel-example) 18 | - 一个能通过所有测例的 `complete kernel reference`:[暂不公布]() 19 | 20 | 目前已经支持 `musl libc-test`, `busybox`, `lua`, `lmbench` 相关Linux App测例,测试过程无人工干预,需要由内核自动运行,所有测例文件放在镜像中,内核需要支持 `fat32` 文件系统来读取文件。 [镜像文件](https://github.com/os-autograding/testsuits-in-one/raw/gh-pages/fat32.img) 21 | 22 | ## 本地测试 23 | 24 | 如你写好OS后,想在在本地测试,评测运行指令如下: 25 | 26 | ```shell 27 | qemu-system-riscv64 \ 28 | -machine virt \ 29 | -bios default \ 30 | -device loader,file=kernel-qemu,addr=0x80200000 \ 31 | -drive file=fat32.img,if=none,format=raw,id=x0 \ 32 | -device virtio-blk-device,drive=x0,bus=virtio-mmio-bus.0 \ 33 | -kernel kernel-qemu \ 34 | -nographic \ 35 | -smp 4 -m 2G 36 | ``` 37 | 38 | ## 在线测试 39 | github的CI对内核进行测试的执行时间设置为 `300` 秒(`5`分钟),超时后程序会被终止,不再继续执行,所得分数为超时前完成的部分的分数。 40 | 41 | github的CI执行完毕后,会在你的repo中的 gp-pages 分支下生成相关的 `log` 文件和 `README` 文件,在 `README` 文件中可以看到当前得到的分数,在 `log` 文件中能看到详细的得分情况。 42 | 43 | ## 注意事项 44 | - `QEMU` 版本为 `7.0.0` 45 | - `RUST ToolChain` 版本为 `nightly-2022-08-08` 46 | - 编译目标架构为 `riscv64imac-unknown-none-elf` 47 | - 内核执行时间为 `8` 分钟 48 | - 内核可用内存大小为 `2G` 49 | - 只有 `main` 分支的提交可以被Github 上的CI评测机处理 50 | - Github 上的CI评测机在初次运行时需要编译 `qemu`,可能需要花费一些时间,请耐心等待 51 | - 所有测例均由`musl-gcc`编译,包括`lmbench`。 52 | - 如果在实践中碰到问题,请在本repo的 `issues` 栏中发帖子 53 | - 如果有进一步的改进,请给本repo提 `Pull requests` 54 | 55 | ## 学习资源 56 | ### 2022OS比赛内核实现赛道一等奖的仓库(包含从初赛到决赛全过程的文档/代码等) 57 | - [北航:图漏图森破](https://gitlab.eduxiji.net/19373469/oskernel2022-x.git) 58 | - [西工大:NPUcore](https://gitlab.eduxiji.net/2019301887/oskernel2022-npucore.git) 59 | - [清华:Maturin](https://gitlab.eduxiji.net/scPointer/maturin.git) 60 | - [哈工大深圳:FTL OS](https://gitlab.eduxiji.net/DarkAngelEX/oskernel2022-ftlos.git) 61 | - [杭电:进击のOS](https://gitlab.eduxiji.net/YzTz/os.git) 62 | - [哈工大深圳:OopS](https://gitlab.eduxiji.net/ZYF_2001/oskernel2022-oops.git) 63 | 64 | ### 训练与比赛信息(丰富的基础OS相关学习与训练资源) 65 | - [与内核赛道相关的一些硬件/OS相关的实例/教程的参考信息](https://github.com/oscomp/os-competition-info/blob/main/ref-info.md) 66 | - [2022暑期开源操作系统训练营](https://learningos.github.io/rust-based-os-comp2022/) 67 | - [2022全国大学生操作系统比赛相关信息-技术报告/学习资料等](https://github.com/oscomp/os-competition-info) 68 | - [全国大学生操作系统比赛官网](https://os.educg.net/) 69 | 70 | ## 致谢 71 | - 杨金博:oscomp-kernel-training github classroom/CI/kernel demo 72 | - 王明健:设计实现测试用例和评测方法等 73 | - 闭浩扬:kernel demo&testing 74 | --------------------------------------------------------------------------------