Skip to content

Refactoring the scheduler (& sleeping) #620

@niaow

Description

@niaow

At the time of writing, the scheduler works as the following loop:

  1. check the time
  2. if the front of the timer queue has already passed, then push the goroutine to the back of the scheduler queue
  3. take the next task on the runqueue
  4. if it is nil, go to sleep and ask for a wakeup; if it is non-nil, run it

This model was built before interrupts were part of the scheduler, and so incorporating interrupts is difficult. At the bare minimum, the timing code needs to be able to return early in case of interrupt so that interrupts can be handled properly.

Our current scheduler also has a few other issues:

  1. When handling large amounts of small events, we spam-check the timer. On some platforms this is very fast, while on others like embedded Linux it can become a bottleneck.
  2. Timing is tightly coupled to the scheduler, which may make it more difficult to make modifications.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions