1.测试条件
写入磁盘,以最小写入单元4kB,一次性写入200MB,写完执行fsync,间隔10s无限循环,测试4h,同时sros在后台运行跑自由导航。
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "test_memory_io.h"
int main(void) {
uint32_t count = 0, i;
FILE *fp = NULL;
uint8_t dst[4096];
int fd ;
uint32_t data_len = (100*1024)/2; // 200MB
memset(dst, 'a', sizeof(dst));
fd = open("test",O_WRONLY | O_CREAT | O_TRUNC,0600);
/* 清空文件 */
ftruncate(fd, 0);
while (1) {
for (i=0;i<data_len; i++) {
write(fd, dst, strlen(dst));
}
fsync(fd);
printf("test memory io r/w, count:%d\n", ++count);
/* 重新设置文件偏移量 */
lseek(fd, 0, SEEK_SET);
sleep(10);
}
close(fd);
return 0;
}
2.tk1 cpu占用率
3.运行磁盘写入测试应用程序
测试时长:1568*10s/3600= 4.36h
4.SRTOS 主循环while监控,最大超时20ms
5.查看sros log.info
SROS出现与SRTOS、VSC通信超时,实际上VSC、SRTOS运行正常没有出现超时
读取SRTOS参数
设置SRTOS参数
6.逻辑分析仪抓包
通道0为SROS,通道1为VSC
发现VSC有1.95s没有接收到任何数据,而SROS与VSC之前设定的超时时间为2S。
7.现象
AGV自由导航一段时间后,出现软件触发急停。
8.深入分析
通过分析sros.INFO发现SROS与VSC、SRTOS通信超时,导致VSC主动发送急停命令给SROS,出现软件触发急停,此时cpu高达90%以上。
为了证明与cpu无关,把定位取消,降低cpu,AGV静止测试,发现VSC依然会触发软件急停。
9.结论
综上所述,应用程序频繁写大文件到文件系统,会导致系统堵塞,同时SROS会误判超时的原因。