From aa8c016aeb0d6283e024caab1665b0c5e02afdd8 Mon Sep 17 00:00:00 2001 From: Naveen Kaje Date: Fri, 6 Nov 2020 15:44:53 -0600 Subject: [PATCH] log: yield periodically while dumping logs The logs are processed in the default task. In cases where there are a lot of logs to be processed, the idle task may get blocked from running, resulting in a watchdog bite. Address this by periodically putting ourselves on the sleep list. Signed-off-by: Naveen Kaje --- sys/log/full/src/log_shell.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sys/log/full/src/log_shell.c b/sys/log/full/src/log_shell.c index cedb1f9649..dbad194ea5 100644 --- a/sys/log/full/src/log_shell.c +++ b/sys/log/full/src/log_shell.c @@ -37,6 +37,9 @@ #include "tinycbor/compilersupport_p.h" #include "log_cbor_reader/log_cbor_reader.h" +/* Global counter to yield so that watchdog is serviced in idle task */ +int g_log_dump_count; + static int shell_log_dump_entry(struct log *log, struct log_offset *log_offset, const struct log_entry_hdr *ueh, const void *dptr, uint16_t len) @@ -93,6 +96,11 @@ shell_log_dump_entry(struct log *log, struct log_offset *log_offset, } console_write("\n", 1); + if ((++g_log_dump_count) == 100) { + g_log_dump_count = 0; + /* Sleep for 5 ticks, to yield */ + os_time_delay(5); + } return 0; }