All Projects → HUST-OS → tornado-os

HUST-OS / tornado-os

Licence: Apache-2.0, Unknown licenses found Licenses found Apache-2.0 LICENSE-Apache Unknown LICENSE-MULAN
异步内核就像风一样快!

Programming Languages

rust
11053 projects
python
139335 projects - #7 most used programming language
assembly
5116 projects

Projects that are alternatives of or similar to tornado-os

Ckb Vm
CKB's vm, based on open source RISC-V ISA
Stars: ✭ 211 (-20.08%)
Mutual labels:  riscv
riscv-meta
RISC-V Instruction Set Metadata
Stars: ✭ 33 (-87.5%)
Mutual labels:  riscv
Onyx
UNIX-like operating system written in C and C++
Stars: ✭ 52 (-80.3%)
Mutual labels:  riscv
platform-shakti
Shakti: development platform for PlatformIO
Stars: ✭ 26 (-90.15%)
Mutual labels:  riscv
freedom-u-sdk
Freedom U Software Development Kit (FUSDK)
Stars: ✭ 246 (-6.82%)
Mutual labels:  riscv
serval-sosp19
This repo contains the artifact for our SOSP'19 paper on Serval
Stars: ✭ 26 (-90.15%)
Mutual labels:  riscv
Riscv Fs
F# RISC-V Instruction Set formal specification
Stars: ✭ 173 (-34.47%)
Mutual labels:  riscv
Zelda.RISCV.Emulator
A System Level RISCV32 Emulator Over x86_64: capable of booting RISCV Linux
Stars: ✭ 18 (-93.18%)
Mutual labels:  riscv
supervisor-rv
计算机组成原理课程 RISC-V 监控程序,支持 32 位和 64 位
Stars: ✭ 93 (-64.77%)
Mutual labels:  riscv
sdfirm
Ultra light weight small device firmware. Well architected to support MMU, SMP, low power idle. Can be run on various CPU architectures.
Stars: ✭ 2 (-99.24%)
Mutual labels:  riscv
kianRiscV
KianRISC-V! No RISC-V, no fun! RISC-V CPU with strong design rules and unittested! CPU you can trust! kianv rv32im risc-v a hdmi soc with harris computer architecture in verilog: multicycle, singlecycle and 5-stage pipelining Processor. Multicycle Soc with firmware that runs raytracer, mandelbrot, 3d hdmi gfx, dma controller, etc.....
Stars: ✭ 167 (-36.74%)
Mutual labels:  riscv
bl602-pac
Embedded Rust's Peripheral Access Crate for BL602 microcontrollers
Stars: ✭ 16 (-93.94%)
Mutual labels:  riscv
SaxonSoc
SoC based on VexRiscv and ICE40 UP5K
Stars: ✭ 112 (-57.58%)
Mutual labels:  riscv
Riscv Mini
Simple RISC-V 3-stage Pipeline in Chisel
Stars: ✭ 221 (-16.29%)
Mutual labels:  riscv
jonesforth riscv
Jonesforth RISC-V port.
Stars: ✭ 50 (-81.06%)
Mutual labels:  riscv
Ppci
A compiler for ARM, X86, MSP430, xtensa and more implemented in pure Python
Stars: ✭ 210 (-20.45%)
Mutual labels:  riscv
tree-core-cpu
A series of RISC-V soft core processor written from scratch. Now, we're using all open-source toolchain( chisel, mill, verilator, NEMU, AM and difftest framework, etc) to design and verify.
Stars: ✭ 22 (-91.67%)
Mutual labels:  riscv
yatcpu
Yet another toy CPU.
Stars: ✭ 42 (-84.09%)
Mutual labels:  riscv
nuclei-sdk
Nuclei RISC-V Software Development Kit
Stars: ✭ 65 (-75.38%)
Mutual labels:  riscv
blflash
bl602 serial flasher
Stars: ✭ 41 (-84.47%)
Mutual labels:  riscv

飓风内核

异步内核就像风一样快!
os ISA competition

基于共享调度器的异步内核设计

操作系统内核经历了几个主要的发展阶段,从裸机应用,批处理系统到多道任务系统,演变为至今主流的线程操作系统。这种系统基于线程的切换来调度任务;为了进一步提升性能,一些现代编程语言在应用层复用线程资源,提出了协程的概念,旨在节省任务调度的开销。
在本项目中我们提出一种新的内核开发思路:由不同资源共享调度器,在操作系统层面提供协程。我们希望这种全新设计的内核在满足传统内核的易用性的同时,拥有着专有内核的高性能特点,“像风一样快”,因此取名飓风内核——tornado-os

运行异步任务

飓风内核中和传统内核最大的不同点就在于多任务的运行方式,在飓风内核中基于共享调度器来运行异步任务,伪代码呈现如下:

pub extern "C" fn kernel_main() {
    // 内核的一些初始化过程
    kernel::init();
    // 共享调度器的基地址
    let base = 0x8600_0000;
    // 实例化共享调度器
    let shared_scheduler = unsafe { task::SharedScheduler::load(base) };
    // 创建一个[`Future`]
    let future = MyFuture::new();
    // 用future创建一个任务
    let task = task::KernelTask::new(future);
    // 往共享调度器里面添加任务
    shared_scheduler.add_task(task);
    // 内核异步运行时中的执行器执行任务
    runtime::executor::run_until_idle();
}

系统架构

如何执行异步任务

如何运行

如果您已经能够运行rCore-Tutorial,那么您的环境已经能满足编译飓风内核的要求,不需要再次安装构建工具,请直接开始下一步。

首先需要准备构建工具:

  • Rust 环境(nightly-2021-03-01或以上),安装方法
  • qemu-system-riscv64(请使用 5.2.0 版本),qemu安装方法
  • riscv64-linux-gnu-系列或riscv64-unknown-elf-系列两种常用的RISC-V工具链,或Rust嵌入式社区的cargo-binutils工具链,其中riscv64-linux-gnu在Ubuntu平台可以使用apt直接安装,cargo-binutils按照github说明安装即可。
  • 调试工具(可选):RISC-V 指令集支持的 gdb

演示视频链接:https://pan.baidu.com/s/11U0_G3tufcu9fksLHryAYQ, 提取码:cym9

下载源码:

git clone https://github.com/HUST-OS/tornado-os.git

在qemu上运行:

cd tornado-os
cargo mkfs # 生成文件镜像
cargo qemu # 运行qemu模拟器

其中,cargo mkfs将生成文件的镜像,它需要在Linux或macOS系统下运行;如果开发环境是Windows,可以考虑在WSL下开发项目。 cargo qemu能在任何的操作系统下运行。

项目直接使用xtask写法,所以不需要安装make、just等脚本工具。如果在编写的过程中要求输入账号密码,可能因为xtask写法而输入失败。 这时候可以使用sudo su等需要特权的Linux命令,输入密码后退出su环境,当前控制台暂时保存权限,此时再运行命令就不需要输入密码了。

在k210上运行:
首先制作sd卡,将sd卡放入读卡器中,连接到PC端,确认您的sd卡分区,假设是/dev/sdb,然后运行以下命令:

cargo mkfs # 生成文件镜像
sudo dd if=fs.img of=/dev/sdb count=1440k # 将文件镜像写入到sd卡中
# 上面这条命令如果长时间没结束可以直接Ctrl+C退出,文件镜像依然会写入到sd卡中

然后将sd卡从读卡器中拔出来插入到k210板子上,将k210板子连接到PC端。 接下来检查您的USB串口,运行命令:

cargo detect

终端会打印出当前您的k210板子对应的USB串口,这里假设是/dev/ttyUSB0

最后运行命令:

sudo chmod 777 /dev/ttyUSB0 # windows平台不需要这步
cargo k210 # 将内核二进制文件烧写到k210中运行

note: k210模式下按Ctrl + ]退出。

如果您需要运行数据库测例,这个样例程序需要额外的依赖库才能运行。请输入cargo mkfs --db来编译,来选择这些依赖库。

演示程序说明请参考这里

Features

内核组件 状态 未来改动
内存管理
中断管理
跳板页切换 (特权级切换)
共享调度器 较小
内核异步运行时 (执行器) 比较大
用户异步运行时 (执行器)
virtio异步块设备驱动
sd卡异步驱动 (未完全) 待实现
virtio异步网卡驱动 待实现
不同地址空间任务切换 (yield系统调用)
保底机制(时钟中断的处理) 待实现
相同地址空间任务通信 (Channel) 较小
不同地址空间任务通信 待实现
性能测试 (需要更精确的测试)
系统调用 状态 实现优先级
yield
异步IO (块设备读写)
exec

目录介绍

目录名称 介绍
tornado-kernel 飓风内核实现
shared-scheduler 共享调度器实现
tornado-user 用户态代码实现
async-virtio-driver 异步virtio块设备驱动
async-fat32 异步fat32文件系统
async-mutex 异步锁
async-sd 异步sd卡驱动
event 事件机制库no_std支持
rv-lock RISC-V指令集关中断的锁

其中共享调度器以二进制包的形式编译,集成一些接口提供给内核和用户,具体实现参考代码
飓风内核中与共享调度器通过 API 兼容方式进行交互,具体参考代码,用户态代码同上,具体请参考代码

开发文档

TODO

  • 从内核层面提供异步网络IO(异步网络协议栈)
  • 更全面,更系统的性能测试分析
  • 多核环境下的上下文管理机制

开源协议

本项目使用双开源协议:

无相之风战队出品

欢迎浏览无相之风战队官方网站

性能测试结果

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].