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
...