Finished proof branch dealing with ready list reordering. Strict positivity of uxCurrentPriority remains to be proven.

This commit is contained in:
Tobias Reinhard 2022-12-06 10:16:22 -05:00
parent e68b45969b
commit f98779f0cb

65
tasks.c
View file

@ -1193,7 +1193,7 @@ static void prvYieldForTask( TCB_t * pxTCB,
//@ assert( foreach(remove(gCurrentTCB, gTasks), readOnly_sharedSeg_TCB_p(gTasks, gStates)) ); //@ assert( foreach(remove(gCurrentTCB, gTasks), readOnly_sharedSeg_TCB_p(gTasks, gStates)) );
//@ assert( foreach(gTasks, readOnly_sharedSeg_TCB_IF_not_running_p(gTasks, gStates)) ); //@ assert( foreach(gTasks, readOnly_sharedSeg_TCB_IF_not_running_p(gTasks, gStates)) );
// New stsates list reflects state update above. // New states list reflects state update above.
//@ list<TaskRunning_t> gStates1 = def_state1(gTasks, gStates, gCurrentTCB, pxTCB); //@ list<TaskRunning_t> gStates1 = def_state1(gTasks, gStates, gCurrentTCB, pxTCB);
//@ assert( nth(index_of(pxTCB, gTasks), gStates1) == taskTASK_NOT_RUNNING); //@ assert( nth(index_of(pxTCB, gTasks), gStates1) == taskTASK_NOT_RUNNING);
@ -1301,48 +1301,37 @@ static void prvYieldForTask( TCB_t * pxTCB,
if( xTaskScheduled != pdFALSE ) if( xTaskScheduled != pdFALSE )
{ {
//@ close exists(gReadyList); //@ close exists(gReadyList);
//@ assume(false);
//@ assert( xLIST(gReadyList, gSize, gIndex, gEnd, gCells, gVals, gOwners) ); //@ assert( xLIST(gReadyList, gSize, gIndex, gEnd, gCells, gVals, gOwners) );
/* Once a task has been selected to run on this core, /* Once a task has been selected to run on this core,
* move it to the end of the ready task list. */ * move it to the end of the ready task list. */
uxListRemove( pxTaskItem ); #ifdef VERIFAST
//@ assert( xLIST(gReadyList, gSize-1, ?gIndex2, gEnd, ?gCells2, ?gVals2, ?gOwners2) ); /* Reasons for rewrite:
//@ assert( forall(gOwners, (mem_list_elem)(gTasks)) == true ); * - Linearization of subproof for performance reasons:
//@ assert( forall(gOwners2, (mem_list_elem)(gTasks)) == true ); * The contracts of `uxListRemove` and `vListInserEnd` introduce case distinctions, i.e.,
vListInsertEnd( pxReadyList, pxTaskItem ); * branch splits in the proof tree. This increases the size of the proof tree exponentially
//@ assert( xLIST(gReadyList, gSize, ?gIndex3, gEnd, ?gCells3, ?gVals3, ?gOwners3) ); * and checking the proof with VeriFast takes very long.
//@ assert( forall(gOwners3, (mem_list_elem)(gTasks)) == true ); * The contract of lemma `VF_reordeReadyList` does not expose these case distinctions.
* Hence, wrapping the function calls inside the lemma linearizes the subproof and
//@ assert( length(gCells3) == length(gCells) ); * improves the performance of VeriFast exponentially.
//@ List_array_join(&pxReadyTasksLists); * - Reasoning about the function calls requires us introduce many temporary new facts
//@ assert( List_array_p(pxReadyTasksLists, configMAX_PRIORITIES, ?gCellLists2, ?gOwnerLists2) ); * about the cell and owner lists by calling list lemmas. Introducing such facts can
// . //@ assert( gCellLists2 == gCellLists ); * easily lead to an infinite loop of auto lemmas calls. Encapsulating the subproof in a
// . //@ assert( gOwnerLists2 == gOwnerLists ); * lemma allows us to ingore facts necessary for different parts of the proof.
* That is, makes it easier to ensure that we don't run into an infinite auto lemma call
* loop.
// We need to prove `forall(gOwnerLists2, (superset)(gTasks)) == true` */
//@ assert( forall(gOwnerLists, (superset)(gTasks)) == true ); /*@ close VF_reordeReadyList__ghost_args
/*@ assert( gOwnerLists2 == (gTasks, gCellLists, gOwnerLists, uxCurrentPriority);
append(gPrefOwnerLists, cons(gOwners3, gSufOwnerLists)) );
@*/ @*/
//@ assert( gPrefOwnerLists == take(uxCurrentPriority, gOwnerLists) ); VF_reordeReadyList( pxReadyList, pxTaskItem);
//@ assert( gSufOwnerLists == drop(uxCurrentPriority + 1, gOwnerLists) ); #else
//@ assert( gOwners == nth(uxCurrentPriority, gOwnerLists) ); uxListRemove( pxTaskItem );
//@ assert( forall(gPrefOwnerLists, (superset)(gTasks)) == true ); vListInsertEnd( pxReadyList, pxTaskItem );
//@ forall_drop(gOwnerLists, (superset)(gTasks), uxCurrentPriority+1); #endif /* VERIFAST */
//@ assert( forall(gSufOwnerLists, (superset)(gTasks)) == true ); //@ assert( readyLists_p(?gReorderedCellLists, ?gReorderedOwnerLists) );
//@ assert( superset(gTasks, gOwners3) == true ); //@ assert( forall(gReorderedOwnerLists, (superset)(gTasks)) == true );
//@ assert( forall(gOwnerLists2, (superset)(gTasks)) == true );
//@ assert( exists_in_taskISRLockInv_p(gTasks, ?gStatesEnd) );
//@ assert( foreach(gTasks, readOnly_sharedSeg_TCB_p(gTasks, gStatesEnd)) );
//@ assert( foreach(gTasks, readOnly_sharedSeg_TCB_IF_not_running_p(gTasks, gStatesEnd)) );
// //@ close [1/2]sharedSeg_TCB_p(pxTCB, _);
//@ close readyLists_p(gCellLists2, gOwnerLists2);
//@ gInnerLoopBroken = true; //@ gInnerLoopBroken = true;
break; break;
} }