Skip to content

Commit ce5c4a6

Browse files
Move errorhandler away from interrupt callback
1 parent 0aaac75 commit ce5c4a6

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

Src/HALAL/Services/Time/Scheduler.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ uint64_t Scheduler::global_tick_us_{0};
3131
uint32_t Scheduler::current_interval_us_{0};
3232
uint16_t Scheduler::timeout_idx_{1};
3333

34+
uint16_t failing_id = Scheduler::INVALID_ID;
35+
3436
// ----------------------------
3537

3638
inline void Scheduler::global_timer_disable() {
@@ -139,6 +141,12 @@ void Scheduler_start(void) {
139141
}
140142

141143
void Scheduler::update() {
144+
// NOTE: Only _one_ id will be shown per call to update()
145+
if(failing_id != Scheduler::INVALID_ID) [[unlikely]] {
146+
ErrorHandler("Too slow, could not execute task %u in time", failing_id);
147+
failing_id = Scheduler::INVALID_ID;
148+
}
149+
142150
while (ready_bitmap_ != 0u) {
143151
uint32_t bit_index = static_cast<uint32_t>(__builtin_ctz(ready_bitmap_));
144152

@@ -305,7 +313,7 @@ inline void Scheduler::on_timer_update() {
305313
pop_front();
306314
// mark task as ready
307315
if ((ready_bitmap_ & task_bit) != 0) [[unlikely]] {
308-
ErrorHandler("Too slow, could not execute task %u in time", candidate_id);
316+
failing_id = candidate_id;
309317
}
310318
SET_BIT(ready_bitmap_, task_bit);
311319
if (task.repeating) [[likely]] {

0 commit comments

Comments
 (0)