From c08a5c55d7c97cfdaf0aacd94303d11bac89a2ea Mon Sep 17 00:00:00 2001 From: pln <Per Lindgren> Date: Sun, 5 Mar 2017 19:14:38 +0000 Subject: [PATCH] prepare for lab (wcet) --- src/main.c | 119 ++++++++++++++++------------------------------------- 1 file changed, 35 insertions(+), 84 deletions(-) diff --git a/src/main.c b/src/main.c index dabf3bb..ff3b78e 100644 --- a/src/main.c +++ b/src/main.c @@ -1,5 +1,4 @@ //#define KLEE -#define JOB 1 #ifdef KLEE #include "SRP_klee.h" @@ -75,6 +74,8 @@ TASK(j2) LOCK(r1); #ifdef enable_itm trace_printf("j2_r1_locked\n"); + work(5); + #endif UNLOCK(r1); #ifdef enable_itm @@ -82,6 +83,28 @@ TASK(j2) #endif } +TASK(j3) { +#ifdef enable_itm + trace_printf("j3_enter\n"); +#endif + LOCK(r1); +#ifdef enable_itm + trace_printf("j3_r1_locked\n"); +#endif + work(1); + + UNLOCK(r1); + JOB_REQUEST(j1); +#ifdef enable_itm + trace_printf("j3_exit\n"); +#endif +} + +#ifdef KLEE_WCET +// will be set by gdb +static volatile int wcet_task; +#endif + int main() { #ifdef enable_itm @@ -94,6 +117,7 @@ int main() DWT->CYCCNT = 0; #ifndef KLEE_WCET + // this will be run in the production code SETPRIO(j1); // Set HW priorities SETPRIO(j2); SETPRIO(j3); @@ -101,8 +125,8 @@ int main() ENABLE(j2); ENABLE(j3); - JOB_REQUEST(j1); // comment out in assignment c - //JOB_REQUEST(j3); // use in assignment c + //JOB_REQUEST(j1); // comment out in assignment c + JOB_REQUEST(j3); // use in assignment c BREAKPOINT; while (1) ; @@ -122,92 +146,19 @@ int main() #elif (JOB == 1) // check task 1 klee_make_symbolic(&state, sizeof(state), "state"); - //IRQh(j1); EXTI1_IRQHandler(); +#elif (JOB == 2) + // check task 2 + klee_make_symbolic(&state, sizeof(state), "state"); + EXTI2_IRQHandler(); +#elif (JOB == 3) + // check task 3 + klee_make_symbolic(&state, sizeof(state), "state"); + EXTI3_IRQHandler(); #endif } -/* enable in assignment c -TASK(j3) { -#ifdef enable_itm - trace_printf("j3_enter\n"); -#endif - LOCK(r2); -#ifdef enable_itm - trace_printf("j3_r2_locked\n"); -#endif - UNLOCK(r2); - JOB_REQUEST(j1); -#ifdef enable_itm - trace_printf("j3_exit\n"); -#endif -} -// -*/ - /* Assignments -a) Run the program, you should get - - 0 Init - 1 j1_enter - 2 j2_enter - 3 j2_r1_locked - 4 j2_exit - 5 j1 after job request j2 - 6 j1_r1_locked, before job request j2 - 7 j1_r1_locked, after job request j2 - 8 j2_enter - 9 j2_r1_locked -10 j2_exit -11 j1_exit - -b) - -Fill in the table - Current prio , System Ceiling, Stack , Pending Tasks - 0 0 , 0 , idle, , {j1} - 1 1 , 0 , idle:j1 , {j2} - 2 2 , 1 , idle:j1:j2, {} - 3 2 , 2 , idle:j1:j2, {} - 4 2 , 1 , idle:j1:j2, {} - 5 1 , 1 , idle:j1 , {} - 6 ? , ? , ? , {?} - 7 ? , ? , ? , {?} - 8 ? , ? , ? , {?} - 9 ? , ? , ? , {?} -10 ? , ? , ? , {?} -11 ? , ? , ? , {?} - -Notice the values are immediately after execution of the -corresponding print. - -Show to teacher(s) - -c) -add a third task at priority 3 - -TASK(j3) { -#ifdef enable_itm - trace_printf("j3_enter\n"); -#endif - LOCK(r2); -#ifdef enable_itm - trace_printf("j3_r2_locked\n"); -#endif - UNLOCK(r2); - JOB_REQUEST(j1); -#ifdef enable_itm - trace_printf("j3_exit\n"); -#endif -} - -Compute and set the new ceiling value(s) -Change line 38, so that - - -make a new table as above for the complete trace - -Show to teacher(s) */ -- GitLab