mcs: bind SC last in ThreadControlSched

This changes the order in MCS of ThreadControlSched:

1. Bind the fault handler
2. Set priorities
3. Bind or unbind scheduling contexts

Signed-off-by: Curtis Millar <curtis.millar@data61.csiro.au>
This commit is contained in:
Curtis Millar 2019-09-10 11:07:41 +10:00
parent 60f9eaa654
commit a5de16d04e

View file

@ -1827,19 +1827,9 @@ exception_t invokeTCB_ThreadControlSched(tcb_t *target, cte_t *slot,
sched_context_t *sc,
thread_control_flag_t updateFlags)
{
exception_t e;
cap_t tCap = cap_thread_cap_new((word_t)target);
if (updateFlags & thread_control_update_sc) {
if (sc != NULL && sc != target->tcbSchedContext) {
schedContext_bindTCB(sc, target);
} else if (sc == NULL && target->tcbSchedContext != NULL) {
schedContext_unbindTCB(target->tcbSchedContext, target);
}
}
if (updateFlags & thread_control_update_fault) {
e = installTCBCap(target, tCap, slot, tcbFaultHandler, fh_newCap, fh_srcSlot);
cap_t tCap = cap_thread_cap_new((word_t)target);
exception_t e = installTCBCap(target, tCap, slot, tcbFaultHandler, fh_newCap, fh_srcSlot);
if (e != EXCEPTION_NONE) {
return e;
}
@ -1853,6 +1843,14 @@ exception_t invokeTCB_ThreadControlSched(tcb_t *target, cte_t *slot,
setPriority(target, priority);
}
if (updateFlags & thread_control_update_sc) {
if (sc != NULL && sc != target->tcbSchedContext) {
schedContext_bindTCB(sc, target);
} else if (sc == NULL && target->tcbSchedContext != NULL) {
schedContext_unbindTCB(target->tcbSchedContext, target);
}
}
return EXCEPTION_NONE;
}
#endif