preemptive
1.0.0
用Rust撰写的Cortex-M3(特别是在蓝色柱布板上)上的最低率OS。它的目的是研究和展示Cortex-M3的基本运行时间的工作原理。
在计算中,先发制人是暂时中断计算机系统执行的任务,而无需合作的任务,并打算在以后恢复任务。执行任务的此类更改称为上下文开关。 ---- Wikipedia
在BREIF中,非抢先操作系统的内核无法中断任务,而先发制体OS的内核可以在不通知任务的情况下将控件收回。
blue-pill板和串行端口接收器。arm-none-eabi工具链和openocd 。rustc 1.37.0-nightly (17e62f77f 2019-07-01) 。 该项目是从草图中构建初步先发制OS的几个阶段的集合。我将确保每章的所有代码都可以编译并运行在blue-pill上。
Chapter5-MultiTasking cd Chapter5-MultiTasking
将blue-pill连接到笔记本电脑。
将引脚PA2连接到串行接收器,带有115200 Baudrate,8个数据位,1个停车位,没有奇偶校验,没有流量控制。
运行openocd :
> openocd
...
Info : using stlink api v2
Info : Target voltage: 3.175214
Info : stm32f1x.cpu: hardware has 6 breakpoints, 4 watchpoints
> cargo run
Finished dev [unoptimized + debuginfo] target(s) in 0.93s
Running `targetthumbv7m-none-eabidebugpreemptive`
Reading symbols from targetthumbv7m-none-eabidebugpreemptive...done.
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x080008fc msp: 0x20005000
Loading section .isr_vector, size 0x40 lma 0x8000000
Loading section .text, size 0x2a08 lma 0x8000040
Start address 0x80008fc, load size 10824
Transfer rate: 14 KB/sec, 5412 bytes/write.
(gdb) continue
Continuing.
结果,您会看到类似串行接收器的输出:
Executing task1!
task1: fib(0)=1
task1: fib(1)=1
task1: fib(2)=2
Executing task2!
task2: is_prime(1)=true
task2: is_prime(2)=true
task2: is_prime(3)=true
Executing task1!
task1: fib(3)=3
task1: fib(4)=5
task1: fib(5)=8
Executing task2!
task2: is_prime(4)=false
task2: is_prime(5)=true
task2: is_prime(6)=false
...