Skip to content

Commit cbf5378

Browse files
committed
Reduce batch size to improve interrupt latency
1 parent 7629ec5 commit cbf5378

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

kernel/timer.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,18 +205,21 @@ static list_node_t *timer_find_node_by_id(uint16_t id)
205205
return NULL;
206206
}
207207

208-
/* Timer tick handler with batch processing */
208+
/* Reduce timer batch processing size for tighter interrupt latency bounds */
209+
#define TIMER_BATCH_SIZE 4
210+
209211
void _timer_tick_handler(void)
210212
{
211213
if (!timer_initialized || list_is_empty(kcb->timer_list))
212214
return;
213215

214216
uint32_t now = mo_ticks();
215-
timer_t *expired_timers[8]; /* Batch process up to 8 timers per tick */
217+
timer_t *expired_timers[TIMER_BATCH_SIZE]; /* Smaller batch size */
216218
int expired_count = 0;
217219

218-
/* Collect all expired timers in one pass */
219-
while (!list_is_empty(kcb->timer_list) && expired_count < 8) {
220+
/* Collect expired timers in one pass, limited to batch size */
221+
while (!list_is_empty(kcb->timer_list) &&
222+
expired_count < TIMER_BATCH_SIZE) {
220223
timer_t *t = (timer_t *) kcb->timer_list->head->next->data;
221224

222225
if (now >= t->deadline_ticks) {

0 commit comments

Comments
 (0)