mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
ticktimer: implement freemutex/freecondition
With these two API Calls, the ticktimer server will no longer grow without bounds. Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
f2c20dfe75
commit
5285346b4e
1 changed files with 51 additions and 0 deletions
|
|
@ -763,6 +763,7 @@ fn main() -> ! {
|
||||||
info!("sender made LockMutex request that was not blocking");
|
info!("sender made LockMutex request that was not blocking");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
api::Opcode::UnlockMutex => {
|
api::Opcode::UnlockMutex => {
|
||||||
let pid = msg.sender.pid();
|
let pid = msg.sender.pid();
|
||||||
if msg.body.is_blocking() {
|
if msg.body.is_blocking() {
|
||||||
|
|
@ -785,6 +786,20 @@ fn main() -> ! {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
api::Opcode::FreeMutex => {
|
||||||
|
let Some(scalar) = msg.body.scalar_message() else {
|
||||||
|
info!("sender tried to free a mutex using a non-scalar message");
|
||||||
|
continue;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Remove all instances of this mutex from the mutex hash
|
||||||
|
mutex_hash
|
||||||
|
.entry(msg.sender.pid())
|
||||||
|
.or_default()
|
||||||
|
.remove(&scalar.arg1);
|
||||||
|
}
|
||||||
|
|
||||||
api::Opcode::WaitForCondition => {
|
api::Opcode::WaitForCondition => {
|
||||||
let pid = msg.sender.pid();
|
let pid = msg.sender.pid();
|
||||||
let Some(scalar) = msg.body.scalar_message_mut() else {
|
let Some(scalar) = msg.body.scalar_message_mut() else {
|
||||||
|
|
@ -930,6 +945,42 @@ fn main() -> ! {
|
||||||
// next timer event to fire.
|
// next timer event to fire.
|
||||||
start_sleep(&mut ticktimer, &mut sleep_heap);
|
start_sleep(&mut ticktimer, &mut sleep_heap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
api::Opcode::FreeCondition => {
|
||||||
|
let pid = msg.sender.pid();
|
||||||
|
let Some(scalar) = msg.body.scalar_message() else {
|
||||||
|
info!(
|
||||||
|
"sender made FreeCondition request that wasn't a Scalar or BlockingScalar Message"
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
};
|
||||||
|
|
||||||
|
if msg.body.is_blocking() {
|
||||||
|
return_type = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
let condvar = scalar.arg1;
|
||||||
|
|
||||||
|
let awaiting = notify_hash
|
||||||
|
.entry(pid)
|
||||||
|
.or_default()
|
||||||
|
.entry(condvar)
|
||||||
|
.or_default();
|
||||||
|
|
||||||
|
// Free all entries in the sleep heap that are waiting for this condition
|
||||||
|
stop_sleep(&mut ticktimer, &mut sleep_heap);
|
||||||
|
for entry in awaiting.drain(..) {
|
||||||
|
// Remove each entry in the timeout set
|
||||||
|
sleep_heap.retain(|_, v| v.sender != entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove all instances of this condvar
|
||||||
|
notify_hash.entry(pid).or_default().remove(&condvar);
|
||||||
|
|
||||||
|
// Resume sleeping
|
||||||
|
start_sleep(&mut ticktimer, &mut sleep_heap);
|
||||||
|
}
|
||||||
|
|
||||||
api::Opcode::InvalidCall => {
|
api::Opcode::InvalidCall => {
|
||||||
error!("couldn't convert opcode");
|
error!("couldn't convert opcode");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue