军事知识服务平台
面向龙芯处理器的Rust抢占式内核设计与实现
Design and Implementation of a Preemptive Kernel for Loongson Processors in Rust
摘要 针对传统C/C++实时内核缺乏语言级编译期内存安全保障的问题,以采用LA464处理器核的龙芯3A5000为参考处理器,面向LoongArch架构基于Rust设计并实现了一个抢占式内核原型.硬件层面,利用LoongArch的寄存器布局与统一异常入口等特性,以专用寄存器直指任务上下文,实现基于固定长度指令序列的上下文切换.安全层面,利用Rust的所有权和借用检查机制收敛不安全操作,unsafe Rust占内核代码的3.1%,并结合通用缺陷分类(CWE)分析了Rust机制对八类典型安全缺陷的防护能力.调度层面,提出以静态优先级为第一排序键、动态剩余截止时间为第二排序键的混合调度算法.QEMU LA464模型上的实验表明,异常入口路径开销与任务数量关系较弱,调度决策开销随任务数量增加而上升.两类一次性任务场景中,混合调度的高优先级任务截止时间达标率均为100%,平均响应时间均为三种策略中最低.其中异构冲突场景的平均响应时间为545.80 ms,较FPPS和EDF分别降低17.8%和20.9%.周期释放场景中,混合调度与EDF的10个任务实例均按时完成,优于FPPS的70%整体达标率.实验结果初步验证了该内核在LoongArch架构适配、Rust安全机制应用和混合调度方面的可行性.
Abstract:
To address the lack of language-level compile-time memory safety protection in traditional C/C++real-time kernels,a preemptive kernel prototype is designed and implemented in Rust for the LoongArch architecture,with the LA464-based Loongson 3A5000 as the reference processor.At the hardware level,LoongArch features,including its register layout and unified exception entry,are exploited to implement context switching through a dedicated context pointer register and a fixed-length instruction sequence.At the safety level,Rust's ownership and borrow-checking mechanisms are used to confine unsafe operations.Unsafe Rust accounts for 3.1%of the ker-nelcode.The protective effects of Rust mechanisms against eight categories of typical security defects are ana-lyzed with reference to the Common Weakness Enumeration(CWE).At the scheduling level,a hybrid algorithm is proposed,using static priority as the primary sorting key and dynamic remaining time to deadline as the second-ary key.Experiments on the QEMU LA464 model show that the exception-entry path overhead is only weakly related to the number of tasks,whereas the scheduling-decision overhead increases with the task count.In both one-shot task scenarios,the hybrid scheduler achieves a 100%deadline-meeting ratio for high-priority tasks and the lowest average response time among the three strategies;in the heterogeneous conflict scenario,its average response time is 545.80 ms,17.8%and 20.9%lower than those of fixed priority preemptive scheduling(FPPS)and earliest deadline first(EDF),respectively.In the periodic-release scenario,all 10 task instances meet their deadlines under both hybrid scheduling and EDF,compared with a 70%overall deadline-meeting ratio under FPPS.The results provide preliminary evidence of the feasibility of the proposed kernel in LoongArch adaptation,Rust safety mechanisms,and hybrid scheduling.
刊 名 制造业自动化 ISTIC
年,卷(期): 2026, 48(9)
分类号: TP316.2
机标分类号: TP332 TN99 TP274.2
在线出版日期: 2026年10月19日