@@ -143,6 +143,7 @@ void Scheduler::update() {
143143 uint32_t bit_index = static_cast <uint32_t >(__builtin_ctz (ready_bitmap_));
144144
145145 Task& task = tasks_[bit_index];
146+
146147 task.callback ();
147148
148149 SchedLock ();
@@ -280,9 +281,9 @@ void Scheduler::schedule_next_interval() {
280281
281282 Scheduler_global_timer->ARR = current_interval_us_ - 1u ;
282283 if (Scheduler_global_timer->CNT > Scheduler_global_timer->ARR ) [[unlikely]] {
283- uint32_t offset = Scheduler_global_timer->CNT - Scheduler_global_timer-> ARR ;
284+ uint32_t cnt_temp = Scheduler_global_timer->CNT ;
284285 Scheduler_global_timer->CNT = 0 ;
285- global_tick_us_ += offset ;
286+ global_tick_us_ += cnt_temp ;
286287 }
287288 }
288289 Scheduler::global_timer_enable ();
@@ -298,11 +299,15 @@ inline void Scheduler::on_timer_update() {
298299 if (diff > 0 ) [[likely]] {
299300 break ; // Task is in the future, stop processing
300301 }
302+ uint32_t task_bit = 1u << candidate_id;
301303
302304 SchedLock ();
303305 pop_front ();
304306 // mark task as ready
305- SET_BIT (ready_bitmap_, 1u << candidate_id);
307+ if ((ready_bitmap_ & task_bit) != 0 ) [[unlikely]] {
308+ ErrorHandler (" Too slow, could not execute task %u in time" , candidate_id);
309+ }
310+ SET_BIT (ready_bitmap_, task_bit);
306311 if (task.repeating ) [[likely]] {
307312 task.next_fire_us = static_cast <uint32_t >(global_tick_us_ + task.period_us );
308313 insert_sorted (candidate_id);
0 commit comments