diff --git a/src/object/tcb.c b/src/object/tcb.c index bebc61f9d..117ecde8c 100644 --- a/src/object/tcb.c +++ b/src/object/tcb.c @@ -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