Skip to content

Commit 6a8744a

Browse files
committed
Reduce stack check frequency
As stack corruption is rare, it is reasonable to check every 32 ticks, reducing interrupt latency.
1 parent eb33d96 commit 6a8744a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

kernel/task.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,10 @@ void dispatch(void)
302302
if (hal_context_save(((tcb_t *) kcb->task_current->data)->context) != 0)
303303
return;
304304

305-
task_stack_check();
305+
/* Do stack check less frequently to reduce overhead */
306+
if (unlikely((kcb->ticks & (STACK_CHECK_INTERVAL - 1)) == 0))
307+
task_stack_check();
308+
306309
list_foreach(kcb->tasks, delay_update, NULL);
307310

308311
/* Hook for real-time scheduler - if it selects a task, use it */

0 commit comments

Comments
 (0)