fix(kernel): fix kill wait-queue cleanup, RegionId tracking, ReleasePages ownership, and SwitchTo scheduler state
This commit is contained in:
@@ -61,6 +61,14 @@ impl Endpoint {
|
||||
!self.waiting_receivers.is_empty()
|
||||
}
|
||||
|
||||
pub fn remove_sender(&mut self, thread: ThreadId) -> bool {
|
||||
self.waiting_senders.remove_thread(thread)
|
||||
}
|
||||
|
||||
pub fn remove_receiver(&mut self, thread: ThreadId) -> bool {
|
||||
self.waiting_receivers.remove_thread(thread)
|
||||
}
|
||||
|
||||
pub fn revoke(&mut self) {
|
||||
self.generation = self.generation.next();
|
||||
}
|
||||
@@ -97,6 +105,15 @@ impl EndpointTable {
|
||||
pub fn destroy(&mut self, id: EndpointId) -> Option<Endpoint> {
|
||||
self.endpoints.get_mut(id.raw() as usize).and_then(|s| s.take())
|
||||
}
|
||||
|
||||
pub fn remove_thread_from_all(&mut self, thread: ThreadId) {
|
||||
for slot in &mut self.endpoints {
|
||||
if let Some(ep) = slot {
|
||||
ep.remove_sender(thread);
|
||||
ep.remove_receiver(thread);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub trait MessagePassing {
|
||||
|
||||
@@ -86,6 +86,21 @@ impl RegionTable {
|
||||
self.regions.get_mut(id.raw() as usize).and_then(|s| s.take())
|
||||
}
|
||||
|
||||
pub fn find_by_base(
|
||||
&self,
|
||||
owner: ProcessId,
|
||||
base: PhysicalAddress,
|
||||
) -> Option<(RegionId, &MemoryRegion)> {
|
||||
for (i, slot) in self.regions.iter().enumerate() {
|
||||
if let Some(region) = slot {
|
||||
if region.owner() == owner && region.base() == base {
|
||||
return Some((RegionId::from_raw(i as u16), region));
|
||||
}
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
pub fn regions_for_process(&self, process: ProcessId) -> impl Iterator<Item = &MemoryRegion> {
|
||||
self.regions
|
||||
.iter()
|
||||
|
||||
@@ -34,6 +34,10 @@ impl MultiCoreScheduler {
|
||||
self.cores[core.raw() as usize].current()
|
||||
}
|
||||
|
||||
pub fn set_current(&mut self, core: CoreId, thread: ThreadId) {
|
||||
self.cores[core.raw() as usize].set_current(thread);
|
||||
}
|
||||
|
||||
fn thread_count_on(&self, core: CoreId) -> usize {
|
||||
self.placements
|
||||
.iter()
|
||||
|
||||
@@ -43,6 +43,10 @@ impl PerCoreScheduler {
|
||||
self.current = None;
|
||||
}
|
||||
|
||||
pub fn set_current(&mut self, thread: ThreadId) {
|
||||
self.current = Some(thread);
|
||||
}
|
||||
|
||||
pub fn highest_waiting_priority(&self) -> Option<Priority> {
|
||||
self.queue.highest_priority()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user