use super::*;
use crate::sched::system::task_system::TaskSystem;
mod dispatch_state;
mod drain_state;
mod owner_deadline;
mod owner_dispatch;
mod owner_idle;
pub(crate) use owner_deadline::{
HardTimerServiceClaim, HardTimerServiceStep, KtimerServiceClaim,
SchedulerDeadlineRqObservation, SoftTimerExpireBatch,
};
use crate::sched::system::cpu::remote::SchedulerDeadlinePublicationState;
#[derive(Clone, Copy)]
#[repr(usize)]
pub(crate) enum SchedulerDeadlineDerivationSource {
ClockEvent,
KtimerService,
Enqueue,
Placement,
ScheduleSelection,
ScheduleNoSwitch,
}
#[derive(Debug)]
pub struct CpuLocal {
owner: CpuId,
remote: Arc<CpuRemote>,
rt_bandwidth: Arc<RootRtBandwidth>,
dispatch: dispatch_state::OwnerDispatchState,
drain: drain_state::OwnerDrainScratch,
_pinned: PhantomPinned,
}
impl CpuLocal {
pub(crate) fn create(
owner: CpuId,
config: TaskSystemConfig,
remote: Arc<CpuRemote>,
rt_bandwidth: Arc<RootRtBandwidth>,
) -> Pin<Box<Self>> {
debug_assert_eq!(owner, remote.owner());
Box::pin(Self {
owner,
remote,
rt_bandwidth,
dispatch: dispatch_state::OwnerDispatchState::new(config),
drain: drain_state::OwnerDrainScratch::new(config),
_pinned: PhantomPinned,
})
}
pub const fn owner(&self) -> CpuId {
self.owner
}
pub fn is_online(&self) -> bool {
self.remote.is_online()
}
pub(crate) fn remote(&self) -> &Arc<CpuRemote> {
&self.remote
}
pub(crate) unsafe fn remote_for_owner(&self) -> &'static CpuRemote {
unsafe { &*Arc::as_ptr(&self.remote) }
}
}