Added preliminary post condition for vTaskSwitchContext

This commit is contained in:
Tobias Reinhard 2022-11-16 14:26:37 -05:00
parent 4eb2fa573e
commit b330847935

28
tasks.c
View file

@ -4128,19 +4128,30 @@ BaseType_t xTaskIncrementTick( void )
void vTaskSwitchContext( BaseType_t xCoreID ) void vTaskSwitchContext( BaseType_t xCoreID )
/*@ requires 0 <= xCoreID &*& xCoreID < configNUM_CORES &*& /*@ requires 0 <= xCoreID &*& xCoreID < configNUM_CORES &*&
locked(nil) &*& xCoreID == coreID_f() &*&
[?f_ISR]isrLock() &*& // access to locks and disabled interrupts
[?f_task]taskLock() &*& locked(nil) &*&
interruptState_p(xCoreID, ?state) &*& [?f_ISR]isrLock() &*&
xCoreID == coreID_f() &*& [?f_task]taskLock() &*&
interruptsDisabled_f(state) == true &*& interruptState_p(xCoreID, ?state) &*&
// opened predicate `coreLocalInterruptInv_p()` interruptsDisabled_f(state) == true &*&
// opened predicate `coreLocalInterruptInv_p()`
pointer(&pxCurrentTCBs[coreID_f], ?gCurrentTCB) &*& pointer(&pxCurrentTCBs[coreID_f], ?gCurrentTCB) &*&
pubTCB_p(gCurrentTCB, 0) &*& pubTCB_p(gCurrentTCB, 0) &*&
integer_(&xYieldPendings[coreID_f], sizeof(BaseType_t), true, _); integer_(&xYieldPendings[coreID_f], sizeof(BaseType_t), true, _);
@*/ @*/
//@ ensures true; /*@ ensures // all locks release and interrupts remain disabled
locked(nil) &*&
[f_ISR]isrLock() &*&
[f_task]taskLock() &*&
interruptState_p(xCoreID, state) &*&
// opened predicate `coreLocalInterruptInv_p()`
pointer(&pxCurrentTCBs[coreID_f], ?gNewCurrentTCB) &*&
pubTCB_p(gNewCurrentTCB, 0) &*&
integer_(&xYieldPendings[coreID_f], sizeof(BaseType_t), true, _);
// Remark: the part of the post condition relating to TCBs will have to change.
@*/
{ {
/* Acquire both locks: /* Acquire both locks:
* - The ISR lock protects the ready list from simultaneous access by * - The ISR lock protects the ready list from simultaneous access by
@ -4253,6 +4264,7 @@ void vTaskSwitchContext( BaseType_t xCoreID )
#endif /* ( configUSE_NEWLIB_REENTRANT == 1 ) && ( configNEWLIB_REENTRANT_IS_DYNAMIC == 0 ) */ #endif /* ( configUSE_NEWLIB_REENTRANT == 1 ) && ( configNEWLIB_REENTRANT_IS_DYNAMIC == 0 ) */
} }
} }
//@ close pubTCB_p(gCurrentTCB, 0);
//@ close taskISRLockInv(); //@ close taskISRLockInv();
//@ consume_taskISRLockInv(); //@ consume_taskISRLockInv();
portRELEASE_ISR_LOCK(); portRELEASE_ISR_LOCK();