manticoreos/manticore

Replace periodic timer interrupt with one-shot timer

Opened this issue · 3 comments

Currently, the APIC timer is configured to run in periodic mode. This will needlessly wake up the CPU, so let's replace the periodic timer with a variable one-shot timer instead.

Hi @penberg: Can I work on the ticket?

Let me give some more background on what is needed here. We currently configure the APIC timer to run periodically. The timer interrupt wakes up any CPU that's blocked in the arch_halt_cpu. For example, the echo server in usr/echod calls epoll_wait in liblinux, which eventually ends up in the sys_wait system call in kernel/syscall.c. The period timer interrupt wakes it up.

However, even if the sys_wait system call was not called, the periodic timer interrupt will happen. The purpose of this improvement is to make the timer interrupt happen only when needed (sometimes referred to as tickless kernel).

You could, for example, implement an arch_timer_setup() function, which programs the APIC to deliver an one-shot interrupt, and call that arch_timer_setup() function from idle() function in kernel/init.c before halting the CPU.

If you then use the echod server as a test case for this.