Search code examples
clinuxtimerinterrupt

User Level Interrupt Handler for Timer


I have to implement a simple os and a virtual machine, for a project, that supports some basic functions. This os will run on the virtual machine and the virtual machine like a normal program in Linux.

Suppose that now is the quantum that the virtual machine is executed.

  1. How is possible to receive some extra timer signals in order to divide the virtual machine execution time in smaller quanta?
  2. How many timers are available in my cpu? (It's more like a general question)
  3. Can I handle timer signals inside the virtual machine with a user lever interrupt handler?

Any help or guidance would be very appreciated. Thank you


Solution

  • I suggest you use exactly 1 interrupt, and organize your timers in either a queue (for few times, e.g. <50) or in a heap, which is quite a quick tree which, at any time, gives you access to the smallest element, that is, the element with the next Timer to be handled.

    Thus you have one interrupt, one handler, and many Timers with associated functions that will be called by that single handler.