sched: Improve timer vs task priority check

Rename sched_tasks_busy() to sched_check_set_tasks_busy() and change
it to only return true if tasks are active (running or requested) for
two consecutive calls.  This makes it less likely that timers will
yield to tasks except when tasks really are notably backlogged.

This also makes it less likely that multiple steppers controlling the
same rail will be interrupted by tasks mid-step.  This should slightly
improve the timing, and make it less likely that a halt during
homing/probing will occur with these steppers taking a different
number of total steps.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor
2024-10-21 14:26:48 -04:00
parent f0a7797712
commit ea546c789b
6 changed files with 15 additions and 11 deletions

View File

@@ -152,7 +152,7 @@ timer_dispatch(void)
// Check if there are too many repeat timers
if (diff < (int32_t)(-timer_from_us(100000)))
try_shutdown("Rescheduled timer in the past");
if (sched_tasks_busy())
if (sched_check_set_tasks_busy())
return;
repeat_count = TIMER_IDLE_REPEAT_COUNT;
}