1.测试条件

写入磁盘,以最小写入单元4kB,一次性写入200MB,写完执行fsync,间隔10s无限循环,测试4h,同时sros在后台运行跑自由导航。

  1. #include <stdio.h>
  2. #include <stdint.h>
  3. #include <string.h>
  4. #include <unistd.h>
  5. #include <sys/types.h>
  6. #include <sys/stat.h>
  7. #include <fcntl.h>
  8. #include "test_memory_io.h"
  9. int main(void) {
  10. uint32_t count = 0, i;
  11. FILE *fp = NULL;
  12. uint8_t dst[4096];
  13. int fd ;
  14. uint32_t data_len = (100*1024)/2; // 200MB
  15. memset(dst, 'a', sizeof(dst));
  16. fd = open("test",O_WRONLY | O_CREAT | O_TRUNC,0600);
  17. /* 清空文件 */
  18. ftruncate(fd, 0);
  19. while (1) {
  20. for (i=0;i<data_len; i++) {
  21. write(fd, dst, strlen(dst));
  22. }
  23. fsync(fd);
  24. printf("test memory io r/w, count:%d\n", ++count);
  25. /* 重新设置文件偏移量 */
  26. lseek(fd, 0, SEEK_SET);
  27. sleep(10);
  28. }
  29. close(fd);
  30. return 0;
  31. }

2.tk1 cpu占用率

image.png
**

3.运行磁盘写入测试应用程序

image.png
image.png
测试时长:1568*10s/3600= 4.36h

4.SRTOS 主循环while监控,最大超时20ms

image.png

5.查看sros log.info

SROS出现与SRTOS、VSC通信超时,实际上VSC、SRTOS运行正常没有出现超时
image.png

读取SRTOS参数
image.png
image.png
image.png
image.png
image.png
设置SRTOS参数
image.png

image.png
image.png

6.逻辑分析仪抓包

通道0为SROS,通道1为VSC
发现VSC有1.95s没有接收到任何数据,而SROS与VSC之前设定的超时时间为2S。
image.png

7.现象

AGV自由导航一段时间后,出现软件触发急停。

8.深入分析

通过分析sros.INFO发现SROS与VSC、SRTOS通信超时,导致VSC主动发送急停命令给SROS,出现软件触发急停,此时cpu高达90%以上。
为了证明与cpu无关,把定位取消,降低cpu,AGV静止测试,发现VSC依然会触发软件急停。
image.png

9.结论

综上所述,应用程序频繁写大文件到文件系统,会导致系统堵塞,同时SROS会误判超时的原因。