Wrote contracts for lock release operations.

This commit is contained in:
Tobias Reinhard 2022-11-16 14:18:03 -05:00
parent 54523ecdce
commit 4eb2fa573e
3 changed files with 25 additions and 4 deletions

View file

@ -103,13 +103,19 @@ predicate taskISRLockInv() =
true;
lemma void get_taskISRLockInv();
lemma void produce_taskISRLockInv();
requires locked(?heldLocks) &*&
heldLocks == cons(?i, cons(?t, nil)) &*&
i == pair(?f_isr, isrLockID_f()) &*&
t == pair(?f_task, taskLockID_f());
ensures locked( cons( pair(_, taskISRLockID_f()), heldLocks) ) &*&
taskISRLockInv();
lemma void consume_taskISRLockInv();
requires locked( cons( pair(_, taskISRLockID_f()), ?otherLocks) ) &*&
taskISRLockInv();
ensures locked(otherLocks);
@*/

View file

@ -53,12 +53,25 @@ void VF__portRESTORE_INTERRUPTS(uint32_t ulState);
#define portGET_TASK_LOCK VF__portGET_TASK_LOCK
void VF__portGET_TASK_LOCK();
//@ requires [?f]taskLock() &*& locked(nil);
//@ ensures taskLockInv() &*& locked( cons( pair(f, taskLockID_f), nil) );
//@ ensures taskLockInv() &*& locked( cons( pair(f, taskLockID_f()), nil) );
#undef portRELEASE_TASK_LOCK
#define portRELEASE_TASK_LOCK VF__portRELEASE_TASK_LOCK
void VF__portRELEASE_TASK_LOCK();
//@ requires taskLockInv() &*& locked( cons( pair(?f, taskLockID_f()), nil) );
//@ ensures [f]taskLock() &*& locked(nil);
#undef portGET_ISR_LOCK
#define portGET_ISR_LOCK VF__portGET_ISR_LOCK
void VF__portGET_ISR_LOCK();
//@ requires [?f]isrLock() &*& locked(?heldLocks);
//@ ensures isrLockInv() &*& locked( cons( pair(f, isrLockID_f), heldLocks) );
//@ ensures isrLockInv() &*& locked( cons( pair(f, isrLockID_f()), heldLocks) );
#undef portRELEASE_ISR_LOCK
#define portRELEASE_ISR_LOCK VF__portRELEASE_ISR_LOCK
void VF__portRELEASE_ISR_LOCK();
//@ requires isrLockInv() &*& locked( cons( pair(?f, isrLockID_f()), ?heldLocks) );
//@ ensures [f]isrLock() &*& locked(heldLocks);
#endif /* VERIFAST_PORT_CONTRACTS_H */