From acbde6e2b0164dfbb019b6a1c36ea4622e9b543b Mon Sep 17 00:00:00 2001 From: ZhiyuanSue <2262387848@qq.com> Date: Sun, 22 Dec 2024 21:07:52 +0800 Subject: [PATCH] add complete signal mcs code, but cannot fix bugs --- sel4_ipc/src/endpoint.rs | 3 --- sel4_ipc/src/transfer.rs | 11 +++++++++++ sel4_task/src/scheduler.rs | 13 ++++++++++++- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/sel4_ipc/src/endpoint.rs b/sel4_ipc/src/endpoint.rs index 4379ce8..31a461a 100644 --- a/sel4_ipc/src/endpoint.rs +++ b/sel4_ipc/src/endpoint.rs @@ -305,7 +305,6 @@ impl endpoint_func for endpoint { can_grant_reply: bool, canDonate: bool, ) { - use sel4_task::{ksCurSC, reply::reply_t, sched_context::sched_context_t}; // sel4_common::println!("send ipc {}",self.get_ep_state() as usize); match self.get_ep_state() { EPState::Idle | EPState::Send => { @@ -451,7 +450,6 @@ impl endpoint_func for endpoint { use core::intrinsics::unlikely; use log::debug; use sel4_common::structures_gen::{cap_tag::cap_reply_cap, notification_t, seL4_Fault_tag}; - use sel4_task::{ksCurSC, sched_context::sched_context_t}; use crate::notification_func; @@ -525,7 +523,6 @@ impl endpoint_func for endpoint { convert_to_mut_type_ref::(replyptr) .push(sender, thread, canDonate); } else { - sel4_common::println!("receive ipc inactive"); set_thread_state(sender, ThreadState::ThreadStateInactive); } } else { diff --git a/sel4_ipc/src/transfer.rs b/sel4_ipc/src/transfer.rs index dd002c6..1685459 100644 --- a/sel4_ipc/src/transfer.rs +++ b/sel4_ipc/src/transfer.rs @@ -339,6 +339,17 @@ impl Transfer for tcb_t { self.tcbArch .set_register(ArchReg::Badge, ntfn.get_ntfnMsgIdentifier() as usize); ntfn.set_state(NtfnState::Idle as u64); + #[cfg(feature="KERNEL_MCS")] + { + maybeDonateSchedContext(self, ntfn); + if let Some(tcbsc)=convert_to_option_mut_type_ref::(self.tcbSchedContext){ + if tcbsc.sc_sporadic(){ + if self.tcbSchedContext == ntfn.get_ntfnSchedContext() as usize && !tcbsc.is_current(){ + tcbsc.refill_unblock_check(); + } + } + } + } return true; } } diff --git a/sel4_task/src/scheduler.rs b/sel4_task/src/scheduler.rs index af44e3e..8a1fbe0 100644 --- a/sel4_task/src/scheduler.rs +++ b/sel4_task/src/scheduler.rs @@ -404,9 +404,20 @@ fn nextDomain() { if ksDomScheduleIdx >= ksDomScheduleLength { ksDomScheduleIdx = 0; } + #[cfg(feature = "KERNEL_MCS")] + { + ksReprogram = true; + } ksWorkUnitsCompleted = 0; ksCurDomain = ksDomSchedule[ksDomScheduleIdx].domain; - ksDomainTime = ksDomSchedule[ksDomScheduleIdx].length; + #[cfg(feature = "KERNEL_MCS")] + { + ksDomainTime = usToTicks(ksDomSchedule[ksDomScheduleIdx].length * US_IN_MS); + } + #[cfg(not(feature = "KERNEL_MCS"))] + { + ksDomainTime = ksDomSchedule[ksDomScheduleIdx].length; + } //FIXME ksWorkUnits not used; // ksWorkUnits }