面向裸核系统的轻量级异步日志方案设计与实现

王鹏彰, 孙浩, 梁剑, 王昊彦

集成电路与嵌入式系统 ›› 0

集成电路与嵌入式系统 ›› 0 DOI: 10.20193/j.ices2097-4191.2026.0029

面向裸核系统的轻量级异步日志方案设计与实现

  • 王鹏彰, 孙浩, 梁剑, 王昊彦
作者信息 +

Design and Implementation of Lightweight Asynchronous Logging Scheme for Bare-Metal Systems

  • WANG Pengzhang, SUN Hao, LIANG Jian, WANG Haoyan
Author information +
文章历史 +

摘要

针对继电保护等实时性要求极高的嵌入式裸核系统,传统同步日志方案存在中断响应延迟高、线程安全性差、资源消耗大等问题,本文提出一种面向裸核系统的轻量级异步日志方案。该方案采用双缓冲区异步写入机制,在中断服务程序中仅保存关键参数原始值,通过后台主循环完成日志格式化与存储操作;利用关中断方式实现临界区保护,确保中断嵌套环境下的线程安全;针对AMP架构与单裸核场景设计统一的日志存储策略,支持日志等级过滤、Hexdump内存转储及掉电安全存储。在瑞芯微4核处理器上的实验结果表明,该方案将单次日志记录耗时降至1.1μs以内,相比标准格式化打印接口性能提升6倍以上,缓冲区峰值占用率65%,且通过双缓冲区设计与流控机制有效保障了系统的高实时性与可靠性。该方案适用于继电保护、工业控制、航空航天等对实时性与可靠性要求极高的嵌入式裸核系统。

Abstract

In real-time embedded bare-metal systems such as relay protection devices, traditional synchronous logging schemes suffer from high interrupt response latency, poor thread safety, and significant resource consumption. This paper proposes a lightweight asynchronous logging scheme tailored for bare-metal systems. The scheme adopts a dual-buffer asynchronous write mechanism: only raw parameter values are saved in interrupt service routines, while log formatting and storage operations are completed in the background main loop. Critical section protection is achieved through interrupt disabling, ensuring thread safety in interrupt nesting environments. A unified storage strategy is designed for both AMP architecture and single-core bare-metal scenarios, supporting log level filtering, Hexdump memory dumping, and power-fail safe storage. Experimental results on the RockChip 4-core processor show that the scheme reduces single log recording time to within 1.1μs, achieving a 6x performance improvement compared to standard formatting printing interfaces, with peak buffer occupancy of 65%. The dual-buffer design and flow control mechanism effectively guarantee high real-time performance and reliability of the system.This solution is suitable for embedded bare-metal systems in fields such as relay protection, industrial control, and aerospace, where real-time performance and reliability are of the utmost importance.

关键词

裸核系统 / 异步日志 / 中断嵌套 / 双缓冲区 / 实时性 / 嵌入式系统

Key words

bare-metal system / asynchronous logging / interrupt nesting / dual buffer / real-time performance / embedded system

引用本文

导出引用
王鹏彰, 孙浩, 梁剑, 王昊彦. 面向裸核系统的轻量级异步日志方案设计与实现[J]. 集成电路与嵌入式系统. 0 https://doi.org/10.20193/j.ices2097-4191.2026.0029
WANG Pengzhang, SUN Hao, LIANG Jian, WANG Haoyan. Design and Implementation of Lightweight Asynchronous Logging Scheme for Bare-Metal Systems[J]. Integrated Circuits and Embedded Systems. 0 https://doi.org/10.20193/j.ices2097-4191.2026.0029

Accesses

Citation

Detail

段落导航
相关文章

/