logging: Improve algorithm for waking up the thread
Use value returned by atomic_inc to decide on action. Previously direct value was used and that could lead to delays in logging processing because thread waking up could be mishandled. Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
This commit is contained in:
parent
56a04a8200
commit
8c0a017cd3
1 changed files with 4 additions and 3 deletions
|
@ -226,16 +226,17 @@ static void detect_missed_strdup(struct log_msg *msg)
|
|||
|
||||
static void z_log_msg_post_finalize(void)
|
||||
{
|
||||
atomic_inc(&buffered_cnt);
|
||||
atomic_val_t cnt = atomic_inc(&buffered_cnt);
|
||||
|
||||
if (panic_mode) {
|
||||
unsigned int key = irq_lock();
|
||||
(void)log_process(false);
|
||||
irq_unlock(key);
|
||||
} else if (proc_tid != NULL && buffered_cnt == 1) {
|
||||
} else if (proc_tid != NULL && cnt == 0) {
|
||||
k_timer_start(&log_process_thread_timer,
|
||||
K_MSEC(CONFIG_LOG_PROCESS_THREAD_SLEEP_MS), K_NO_WAIT);
|
||||
} else if (CONFIG_LOG_PROCESS_TRIGGER_THRESHOLD) {
|
||||
if ((buffered_cnt == CONFIG_LOG_PROCESS_TRIGGER_THRESHOLD) &&
|
||||
if ((cnt == CONFIG_LOG_PROCESS_TRIGGER_THRESHOLD) &&
|
||||
(proc_tid != NULL)) {
|
||||
k_timer_stop(&log_process_thread_timer);
|
||||
k_sem_give(&log_process_thread_sem);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue