refinement based verification of freertos in
play

Refinement-based Verification of FreeRTOS in VCC 1 Sumesh Divakaran - PowerPoint PPT Presentation

Ref. for FC FreeRTOS Verification Refinement-based Verification of FreeRTOS in VCC 1 Sumesh Divakaran Department of Computer Science Government Engineering College Idukki 11 December 2017, ACM Winter School in SE @ TCS, Pune 1 PhD work @ IISc


  1. Ref. for FC FreeRTOS Verification Refinement-based Verification of FreeRTOS in VCC 1 Sumesh Divakaran Department of Computer Science Government Engineering College Idukki 11 December 2017, ACM Winter School in SE @ TCS, Pune 1 PhD work @ IISc under the supervision of Prof. Deepak D’Souza

  2. Ref. for FC FreeRTOS Verification Outline Refinement for Proving Functional Correctness 1 Motivating Example Refinement Theory Example for Refinement Phrasing Refinement Conditions in VCC FreeRTOS Verification 2 About FreeRTOS FreeRTOS Verification Strategy Steps in FreeRTOS Verification Bugs found in FreeRTOS Verification

  3. Ref. for FC FreeRTOS Verification Motivating Example Motivating example for Functional Correctness FreeRTOS : A popular open-source real time operating system for embedded software applications. It provides API to create and manage multiple tasks. Ready but− Running not running Ready Deleted Blocked Delayed Task states Functional correctness : Need to prove that each behaviour exhibited by the implementation is an expected behaviour of the system

  4. Ref. for FC FreeRTOS Verification Motivating Example Example FreeRTOS application and its behaviour int main(void){ xTaskCreate(foo, "Task A1", 1, ...); xTaskCreate(bar, "Task B2", 2, ...); vTaskStartScheduler(); } Task B2 void foo(void* params){ Task A1 for(;;); } t 1 t 2 t 3 t 4 t 5 void bar(void* params){ Time (tick interrupts) for(;;){ vTaskDelay(2); } }

  5. Ref. for FC FreeRTOS Verification Motivating Example A mechanism for proving functional correctness 1 Develop an abstract mathematical model of the system, precisely representing the required behaviours One can use an Abstract Data Type (ADT) to model the requirements of a system 2 Prove that the given concrete implementation conforms to the mathematical model One can use refinement to establish that a concrete implementation conforms to a mathematical model (ADT)

  6. Ref. for FC FreeRTOS Verification Refinement Theory ADT type An ADT type is a finite set N of operations . For example, FreeRTOS could be an ADT type with operations: xTaskCreate , vTaskStartScheduler and vTaskDelay Each operation n in N has an associated input type I n and an output type O n , each of which is simply a set of values. For example, consider the operation vTaskDelay in the type FreeRTOS I vTaskDelay = N and O vTaskDelay = {} We require that the set of operations N includes a designated initialization operation called init .

  7. Ref. for FC FreeRTOS Verification Refinement Theory A simple example for ADT type: DoubleUIntType ADT type DoubleUIntType = { init , increment , decrement } with I init = { nil } , O init = { ok } , I increment = { nil } , O increment = { ok , fail } , I decrement = { nil } , O decrement = { ok , fail } . Here nil is a “dummy” argument for the operations. The operations are assumed to return the dummy value ok on successful completion.

  8. Ref. for FC FreeRTOS Verification Refinement Theory ADT definition An ADT of type N is a structure of the form A = ( Q , U , { op n } n ∈ N ) where Q is the set of states of the ADT, U ∈ Q is an arbitrary state in Q used as an uninitialized state, Each op n is a (possibly non-deterministic) realisation of the operation n given by op n ⊆ ( Q × I n ) × ( Q × O n ) (a relation which relates a (state, input) pair to a set of (state, output) pairs) Further, we require that the init operation depends only on its argument and not on the originating state: thus init ( p , a ) = init ( q , a ) for each p , q ∈ Q and a ∈ I init .

  9. Ref. for FC FreeRTOS Verification Refinement Theory ADT example: DoubleUInt of type DoubleUIntType DoubleUInt DoubleUInt = ( Q , U , { op n } n ∈ DoubleUIntType ) where Q = { n ∈ N | n < ( UMAX + 1 ) ∗ ( UMAX + 1 ) } where the operations: op init , op increment and op decrement are given by: op init ( n , nil ) = { ( 0 , ok ) | ∀ n ∈ N , n < ( UMAX + 1 ) ∗ ( UMAX + 1 ) } op increment ( n , nil ) = { ( n + 1 , ok ) | ∀ n ∈ N , n + 1 < ( UMAX + 1 ) ∗ ( UMAX + 1 ) } op decrement ( n , nil ) = { ( n − 1 , ok ) | ∀ n ∈ N , 0 < n < ( UMAX + 1 ) ∗ ( UMAX + 1 ) }

  10. Ref. for FC FreeRTOS Verification Refinement Theory Language of sequences of operation calls of an ADT An ADT A = ( Q , U , { op n } n ∈ N ) of type N induces a transition system S A = ( Q , Σ N , U , ∆) where Σ N = { ( n , a , b ) | n ∈ N , a ∈ I n , b ∈ O n } is the set of operation call labels corresponding to the ADT type N . The action label ( n , a , b ) represents a call to operation n with input a that returns the value b . ∆ is given by ( p , ( n , a , b ) , q ) ∈ ∆ iff op n ( p , a , q , b ) . We define the language of initialised sequences of operation calls of A , denoted L init ( A ) , to be L ( S A ) ∩ { ( init , a , b ) · Σ ∗ N | a ∈ I init and b ∈ O init } .

  11. Ref. for FC FreeRTOS Verification Refinement Theory Example: Transition system induced by DoubleUInt TS induced by DoubleUInt ( increment , nil , ok ) ( increment , nil , ok ) ( init , nil , ok ) 0 1 UMAX−1 UMAX ( decrement , nil , ok ) ( decrement , nil , ok )

  12. Ref. for FC FreeRTOS Verification Refinement Theory Totalized version of an ADT A Given an ADT A = ( Q , U , { op n } n ∈ N ) over a data type N , define the totalized version of A , to be an ADT A + of type N + : A + = ( Q ∪ { E } , U , { op + n } n ∈ N ) , where N + has input type I n and output type O + n = O n ∪ {⊥} , where ⊥ is a new output value. E is a new “error” state op + n is the completed version of operation op n , obtained as follows: If ( q , a ) �∈ pre ( op n ) , then add ( q , a , E , b ′ ) to op + n for each b ′ ∈ O + n . n for each a ∈ I n and b ′ ∈ O + Add ( E , a , E , b ′ ) ∈ op + n . Here pre ( op n ) is the set of state-input pairs on which op n is defined. Thus ( p , a ) ∈ pre ( op n ) iff ∃ q , b such that op n ( p , a , q , b ) . If op n is invoked outside this precondition, the data-structure is assumed to “break” and allow any possible interaction sequence after that. A + represents the interaction sequences that a client of A may encounter while using A as a data-structure.

  13. Ref. for FC FreeRTOS Verification Refinement Theory Example: Transition system induced by DoubleUInt + TS induced by DoubleUInt + ( increment , nil , ok ) ( increment , nil , ok ) ( init , nil , ok ) 0 1 UMAX−1 UMAX ( decrement , nil , ok ) ( decrement , nil , ok ) ( decrement , nil , ⊥ ) ( increment , nil , ⊥ ) E ( − , − , ⊥ )

  14. Ref. for FC FreeRTOS Verification Refinement Theory Refinement between ADTs Let A and B be ADTs of type N . We say B refines A , written B � A , iff L init ( B + ) ⊆ L init ( A + ) . Thus every interaction sequence that a client may see with B is also an interaction sequence it could have seen with A . This notion of refinement is from Hoare, He, Sanders et al, Data Refinement Refined , Oxford Univ Report, 1985. Example of refinement: TS induced by DoubleUInt ′ ( decrement , nil , fail ) ( increment , nil , fail ) ( increment , nil , ok ) ( increment , nil , ok ) ( init , nil , ok ) 0 1 UMAX−1 UMAX ( decrement , nil , ok ) ( decrement , nil , ok )

  15. Ref. for FC FreeRTOS Verification Refinement Theory Refinement Condition (RC) ( init , a , b ) q a a ∈ pre ( init A ) (init) = ⇒ and ρ ( init , a , b ) ( init , a , b ) q ′ q ′ a a ( n , a , b ) ( n , a , b ) p p ρ = ρ (g−weak) ⇒ ( n , a , b ′ ) p ′ p ′ ( n , a , b ′ ) ( n , a , b ) p p q (sim) ρ = ⇒ ρ ρ ( n , a , b ) ( n , a , b ) p ′ q ′ p ′ q ′

  16. Ref. for FC FreeRTOS Verification Refinement Theory Condition (RC) is sufficient for refinement If A and C are ADTs of the same type, and ρ is an abstraction relation from C to A satisfying condition (RC), then C refines A . ( init , a , b ) ( n 2 , a 2 , b ) 2 ( n k − 1 , a k − 1 , b k − 1 ) ( n k , a k , b k ) q 1 q 2 q k − 1 q k ρ ρ ρ ρ ( init , a , b ) ( n 2 , a 2 , b 2 ) ( n k − 1 , a k − 1 , b k − 1 ) ( n k , a k , b k ) q ′ q ′ q ′ q ′ 1 2 k − 1 k

  17. Ref. for FC FreeRTOS Verification Refinement Theory Condition (RC) is sufficient for refinement If A and C are ADTs of the same type, and ρ is an abstraction relation from C to A satisfying condition (RC), then C refines A . ( init , a , b ) ( n 2 , a 2 , b ) 2 ( n k − 1 , a k − 1 , b k − 1 ) ( n k , a k , b k ) q 1 q 2 q k − 1 q k ρ ρ ρ ρ ( init , a , b ) ( n 2 , a 2 , b 2 ) ( n k − 1 , a k − 1 , b k − 1 ) ( n k , a k , b k ) q ′ q ′ q ′ q ′ 1 2 k − 1 k

  18. Ref. for FC FreeRTOS Verification Refinement Theory Condition (RC) is sufficient for refinement If A and C are ADTs of the same type, and ρ is an abstraction relation from C to A satisfying condition (RC), then C refines A . ( init , a , b ) ( n 2 , a 2 , b ) 2 ( n k − 1 , a k − 1 , b k − 1 ) ( n k , a k , b k ) q 1 q 2 q k − 1 q k ρ ρ ρ ρ ( init , a , b ) ( n 2 , a 2 , b 2 ) ( n k − 1 , a k − 1 , b k − 1 ) ( n k , a k , b k ) q ′ q ′ q ′ q ′ 1 2 k − 1 k

  19. Ref. for FC FreeRTOS Verification Refinement Theory Condition (RC) is sufficient for refinement If A and C are ADTs of the same type, and ρ is an abstraction relation from C to A satisfying condition (RC), then C refines A . ( init , a , b ) ( n 2 , a 2 , b ) 2 ( n k − 1 , a k − 1 , b k − 1 ) ( n k , a k , b k ) q 1 q 2 q k − 1 q k ρ ρ ρ ρ ( init , a , b ) ( n 2 , a 2 , b 2 ) ( n k − 1 , a k − 1 , b k − 1 ) ( n k , a k , b k ) q ′ q ′ q ′ q ′ 1 2 k − 1 k

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend