Skip to content

Commit

Permalink
try to fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhiyuanSue committed Dec 19, 2024
1 parent 4eb3fb4 commit 72d660a
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 29 deletions.
12 changes: 7 additions & 5 deletions sel4_ipc/src/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,11 +345,13 @@ impl endpoint_func for endpoint {
.refill_ready()
);
set_thread_state(dest_thread, ThreadState::ThreadStateRunning);
if let Some(sc) = convert_to_option_mut_type_ref::<sched_context_t>(dest_thread.tcbSchedContext){
if sc.sc_sporadic() &&dest_thread.tcbSchedContext != unsafe { ksCurSC }{
sc.refill_unblock_check();
}
}
if let Some(sc) =
convert_to_option_mut_type_ref::<sched_context_t>(dest_thread.tcbSchedContext)
{
if sc.sc_sporadic() && dest_thread.tcbSchedContext != unsafe { ksCurSC } {
sc.refill_unblock_check();
}
}
possible_switch_to(dest_thread);
}
}
Expand Down
1 change: 1 addition & 0 deletions sel4_ipc/src/notification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ impl notification_func for notification {
{
self.maybeReturnSchedContext(recv_thread);
if recv_thread.tcbSchedContext != unsafe { ksCurSC }
&& recv_thread.tcbSchedContext != 0
&& convert_to_mut_type_ref::<sched_context_t>(recv_thread.tcbSchedContext)
.sc_sporadic()
{
Expand Down
10 changes: 7 additions & 3 deletions sel4_ipc/src/transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,12 @@ impl Transfer for tcb_t {
assert!(receiver.tcbState.get_replyObject() == 0);
assert!(reply.replyTCB == 0);

let sc = convert_to_mut_type_ref::<sched_context_t>(receiver.tcbSchedContext);
if sc.sc_sporadic() && !sc.is_current() {
sc.refill_unblock_check();
if let Some(sc) =
convert_to_option_mut_type_ref::<sched_context_t>(receiver.tcbSchedContext)
{
if sc.sc_sporadic() && !sc.is_current() {
sc.refill_unblock_check();
}
}

let fault_type = receiver.tcbFault.get_tag();
Expand All @@ -374,6 +377,7 @@ impl Transfer for tcb_t {
}
}
if receiver.tcbSchedContext != 0 && receiver.is_runnable() {
let sc = convert_to_mut_type_ref::<sched_context_t>(receiver.tcbSchedContext);
if sc.refill_ready() && sc.refill_sufficient(0) {
possible_switch_to(receiver);
} else {
Expand Down
1 change: 0 additions & 1 deletion sel4_task/src/reply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ impl reply {
set_thread_state(tcb, ThreadState::ThreadStateInactive);
}
pub fn push(&mut self, tcb_caller: &mut tcb_t, tcb_callee: &mut tcb_t, canDonate: bool) {

assert!(tcb_caller.get_ptr() != 0);
assert!(self.get_ptr() != 0);
assert!(self.replyTCB == 0);
Expand Down
2 changes: 1 addition & 1 deletion sel4_task/src/sched_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ impl sched_context {
}
#[inline]
pub fn sc_sporadic(&self) -> bool {
self.get_ptr() != 0 && self.sc_active() && self.scSporadic
self.sc_active() && self.scSporadic
}
#[inline]
pub fn postpone(&self) {
Expand Down
22 changes: 10 additions & 12 deletions sel4_task/src/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -698,24 +698,22 @@ pub fn commitTime() {
}
#[cfg(feature = "KERNEL_MCS")]
pub fn switch_sched_context() {
use sel4_common::utils::convert_to_option_mut_type_ref;

let thread = get_currenct_thread();
unsafe {
if unlikely(ksCurSC != thread.tcbSchedContext) {
ksReprogram = true;
if convert_to_mut_type_ref::<sched_context_t>(thread.tcbSchedContext)
.sc_constant_bandwidth()
if let Some(sc) =
convert_to_option_mut_type_ref::<sched_context_t>(thread.tcbSchedContext)
{
convert_to_mut_type_ref::<sched_context_t>(thread.tcbSchedContext)
.refill_unblock_check();
}
if sc.sc_constant_bandwidth() {
sc.refill_unblock_check();
}

assert!(
convert_to_mut_type_ref::<sched_context_t>(thread.tcbSchedContext).refill_ready()
);
assert!(
convert_to_mut_type_ref::<sched_context_t>(thread.tcbSchedContext)
.refill_sufficient(0)
);
assert!(sc.refill_ready());
assert!(sc.refill_sufficient(0));
}
}

if ksReprogram {
Expand Down
16 changes: 9 additions & 7 deletions sel4_task/src/tcb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ use sel4_common::structures_gen::{
cap, cap_reply_cap, cap_tag, lookup_fault, lookup_fault_Splayed, mdb_node, seL4_Fault,
seL4_Fault_CapFault, seL4_Fault_tag, thread_state,
};
use sel4_common::utils::{convert_to_mut_type_ref, pageBitsForSize};
use sel4_common::utils::{
convert_to_mut_type_ref, convert_to_option_mut_type_ref, pageBitsForSize,
};
#[cfg(feature = "ENABLE_SMP")]
use sel4_common::BIT;
use sel4_common::MASK;
Expand Down Expand Up @@ -546,14 +548,14 @@ impl tcb_t {
{
// MCS
set_thread_state(self, ThreadState::ThreadStateRestart);
if convert_to_mut_type_ref::<sched_context_t>(self.tcbSchedContext).sc_sporadic()
&& self.tcbSchedContext != unsafe { ksCurSC }
if let Some(sc) =
convert_to_option_mut_type_ref::<sched_context_t>(self.tcbSchedContext)
{
convert_to_mut_type_ref::<sched_context_t>(self.tcbSchedContext)
.refill_unblock_check();
if sc.sc_sporadic() && self.tcbSchedContext != unsafe { ksCurSC } {
sc.refill_unblock_check();
}
sc.schedContext_resume();
}
convert_to_mut_type_ref::<sched_context_t>(self.tcbSchedContext)
.schedContext_resume();
if self.is_schedulable() {
possible_switch_to(self);
}
Expand Down

0 comments on commit 72d660a

Please sign in to comment.