fix: 修复重复执行内存用例导致系统卡死问题

背景:重复执行内存测试用例约几百次,系统大概率出现卡死现象,经分析知,系统卡在
内存spinlock锁中,CPU1在获取内存spinlock锁后打印异常信息,此时循环buffer满了,
CPU0此时进入异常且尝试拿取内存spinlock锁,两个核都处于锁中断锁任务状态,CPU1
写事件触发调度打印输出失败,进而在write接口中死循环无法退出,导致两个核都卡住。
方案:在write接口中增加一个判断条件:当前核处于锁任务状态且循环buffer满了时候,
直接退出循环,丢弃打印信息(持有spinlock锁后一般禁止输出打印信息)。

close #I4F7PO

Signed-off-by: Haryslee <lihao189@huawei.com>
Change-Id: I3f49a1bb211821e9c5d1d220d6867962d6a45a79
This commit is contained in:
Haryslee 2021-12-29 14:27:11 +08:00
parent 979a8a8f27
commit 6c2b163c7d
1 changed files with 2 additions and 1 deletions

View File

@ -47,6 +47,7 @@
#include "los_excinfo_pri.h"
#endif
#include "los_exc_pri.h"
#include "los_sched_pri.h"
#define SIZEBUF 256
@ -94,7 +95,7 @@ STATIC VOID ConsoleOutput(const CHAR *str, UINT32 len)
for (;;) {
cnt = write(STDOUT_FILENO, str + written, (size_t)toWrite);
if ((cnt < 0) || ((cnt == 0) && (OS_INT_ACTIVE)) || (toWrite == cnt)) {
if ((cnt < 0) || ((cnt == 0) && ((!OsPreemptable()) || (OS_INT_ACTIVE))) || (toWrite == cnt)) {
break;
}
written += cnt;