Every entry into the sleep_heap() should be unique. Any insert()
call that returns a value means we're going to drop a wake-up event.
Add an assert()! that will trigger a panic if this invariant is not
met.
Add back in the ability to pre-unlock a Mutex. This is used for slow
path unlocking without needing to wait for a response.
Signed-off-by: Sean Cross <sean@xobs.io>
This rewrites the Mutex and Condvar backends after gaining a better
understanding of how they're supposed to work.
Additionally, the Ticktimer backend implementation has changed:
* There is now a `recalculate_sleep_offline()` call that skips starting
and stopping the ticktimer. This is an unsafe function because the
user must manually manage the ticktimer state. It is used to perform
multiple operations while the ticktimer is unscheduled.
* Ticktimers now deal in `TimerRequest` types rather than raw `i64`
types. This is a newtype that is distinct from the previous `i64`, but
should behave largely the same.
* Waking a Condvar now reports the number of items that were awoken,
provided the requester sends a blocking scalar value. This allows for
backwards compatibility.
* Attempting to wake 0 Condvars now wakes all pending Condvars.
* We no longer keep track of lock-then-unlock for Mutexes, nor
notify-then-wait for Condvars. This makes those cases undefined
behavior, which puts us in line with Posix. Don't unlock mutexes that
haven't been locked, or notify Condvar recipients when nobody is
waiting.
Signed-off-by: Sean Cross <sean@xobs.io>
all other functions have a .init() routine that handles interrupt
binding.
ticktimer rolls that into a routine that also resets the time
of the ticktimer. A comment is added for maintaner sanity down
the road.
Wait until the outside of `new()` in order to install the irq handler.
This is due to a change in the optimizer for 1.71.0 which has exposed
unsoundness.
Signed-off-by: Sean Cross <sean@xobs.io>
The previous condvar implementation was unsound, and didn't do the right
thing. Overhaul condvars so that they now pass the libstd tests.
As part of this, function calls were added to free the mutex and condvar
objects that may have been allocated.
Signed-off-by: Sean Cross <sean@xobs.io>
Rewrite the RecalculateSleep opcode handler so that it will only be
processed if sent by our own process.
As part of this rewrite, use the new `let else` pattern.
Signed-off-by: Sean Cross <sean@xobs.io>
Convert the ticktimer server to use the new
reply_and_receive_next_legacy() call. This is an example of how to use
this API for future projects.
Signed-off-by: Sean Cross <sean@xobs.io>
In general, hosted mode is assumed "by default" if the target
is not Xous. This allows packages to be built cleanly on command
lines that don't know to pass a --feature flag to specify a target.
However, an explicit "hosted" flag is still retained so that we
can confirm the build system intent. This saves us from the failure
mode that we thought we were building for target A, but accidentally
ommitted the flag, and instead we've been silently building for
"hosted" mode without any warning. The main consumer of the "hosted"
flag is now just the build.rs script inside of the utralib.