Skip to content

Commit ee8abd4

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 ee8abd4

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

sys/log/full/src/log_shell.c

Lines changed: 9 additions & 0 deletions
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,12 @@ 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+
{
101+
g_log_dump_count = 0;
102+
/* Sleep for 5 ticks, to yield */
103+
os_time_delay(5);
104+
}
96105
return 0;
97106
}
98107

0 commit comments

Comments
 (0)