Skip to content

Commit aa8c016

Browse files
author
Naveen Kaje
committed
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 <[email protected]>
1 parent a68da01 commit aa8c016

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

sys/log/full/src/log_shell.c

+8
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737
#include "tinycbor/compilersupport_p.h"
3838
#include "log_cbor_reader/log_cbor_reader.h"
3939

40+
/* Global counter to yield so that watchdog is serviced in idle task */
41+
int g_log_dump_count;
42+
4043
static int
4144
shell_log_dump_entry(struct log *log, struct log_offset *log_offset,
4245
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,
9396
}
9497

9598
console_write("\n", 1);
99+
if ((++g_log_dump_count) == 100) {
100+
g_log_dump_count = 0;
101+
/* Sleep for 5 ticks, to yield */
102+
os_time_delay(5);
103+
}
96104
return 0;
97105
}
98106

0 commit comments

Comments
 (0)