Skip to content

Commit

Permalink
log: yield periodically while dumping logs
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Naveen Kaje committed Nov 9, 2020
1 parent a68da01 commit aa8c016
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions sys/log/full/src/log_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit aa8c016

Please sign in to comment.