Use deadlines for sleep, rather than calculating the amount of remaining
time.
This keeps time consistent, because it means we don't have to
recalculate all sleeps whenever one expires.
It also allows us to take advantage of the hardware which will fire an
interrupt if we schedule a wakeup in the past.
Signed-off-by: Sean Cross <sean@xobs.io>
If we switch to a thread and specify a thread ID, remember that as the
current thread ID.
This prevents thread starvation by repeatedly going back to the same
thread ID.
Signed-off-by: Sean Cross <sean@xobs.io>
Previously, we would only look at the top item on the server queue. If
it was not a known message, we would return an error.
This patch changes this behavior to look through the entire queue for
something we can take, and then clean it up as we go along.
This allow for having outstanding requests in the queue an forms the
backbone of the sleep server.
Signed-off-by: Sean Cross <sean@xobs.io>
When claiming an IRQ, we used to disable interrupts.
This is unnecessary, as interrupts are already disabled when running in
kernel mode.
Signed-off-by: Sean Cross <sean@xobs.io>
Keep interrupts nominally disabled in supervisor mode, and only enable
them for a brief period after WFI hits.
If an interrupt occurs, then WFI becomes a NOP. The `idle()` function is
only called when no more processes are running, which happens when all
processes are waiting for an interrupt.
Therefore, enable interrupts for a brief period when WFI returns in
order to drain all pending interrupts and return to the caller to handle
any change in the process table.
Signed-off-by: Sean Cross <sean@xobs.io>
When the kernel is running its main loop, interrupts are disabled as it
is running in supervisor mode.
As a result, we can ignore any interrupt enabling/disabling that may
need to occur.
Signed-off-by: Sean Cross <sean@xobs.io>
This feature works around a bug in Renode where unwrapped lines cause it
to crash. This forces columns to be wrapped at 80 characters.
Signed-off-by: Sean Cross <sean@xobs.io>
Due to a race condition, an IRQ was always fired when the timer was
turned on.
Force a recalculation of the IRQ state when the IRQ is turned on to
avoid firing an interrupt when none should fire.
Signed-off-by: Sean Cross <sean@xobs.io>
Bring the two branches up to date, while also laying the groundwork
for XousServerName to be used as a native index type in xous-names
so we aren't burdening xous::String with a hasher