Skip to content
Snippets Groups Projects
Commit 03cb7333 authored by Henrik Tjäder's avatar Henrik Tjäder
Browse files

Fixed the macro and formatted main

parent 8877d8a0
No related branches found
No related tags found
No related merge requests found
...@@ -44,14 +44,15 @@ typedef struct locks ...@@ -44,14 +44,15 @@ typedef struct locks
} locks; } locks;
uint32_t event_count = 0;
#define MAX_NUM_LOCKS 10
int event_count = 0;
/* Create array containing structs of type locks */ /* Create array containing structs of type locks */
#define MAX_NUM_LOCKS 10
locks eventlist[MAX_NUM_LOCKS]; locks eventlist[MAX_NUM_LOCKS];
//#define TRACE_EVENT(event, el)({eventlist[event_count].time = DWT->CYCCNT; eventlist[event_count].action = event; eventlist[event_count].elem = el; event_count+=1;})
#define TRACE_EVENT(event, el)({}) #define TRACE_EVENT(event, el)({eventlist[event_count].time = DWT->CYCCNT; eventlist[event_count].action = event; eventlist[event_count].elem = el; event_count+=1;})
// #define Ceiling(R) (R##_Ceiling) // #define Ceiling(R) (R##_Ceiling)
...@@ -64,8 +65,8 @@ locks eventlist[MAX_NUM_LOCKS]; ...@@ -64,8 +65,8 @@ locks eventlist[MAX_NUM_LOCKS];
// #define BARRIER_UNLOCK { } // #define BARRIER_UNLOCK { }
#define JOB_REQUEST(J) { } #define JOB_REQUEST(J) { }
#define LOCK(R) TRACE_EVENT(L, #R); #define LOCK(X) TRACE_EVENT(L, X);
#define UNLOCK(R) TRACE_EVENT(R, #R); #define UNLOCK(X) TRACE_EVENT(R, X);
// #define SETPRIO(J) { } // #define SETPRIO(J) { }
// #define ENABLE(J) { } // #define ENABLE(J) { }
......
...@@ -31,23 +31,30 @@ ...@@ -31,23 +31,30 @@
static int state; static int state;
void work(int i) { void work(int i)
{
volatile int k =0; volatile int k =0;
for (int j =0; j < 100 * i; j++) for (int j =0; j < 100 * i; j++)
{
k++; k++;
} }
}
TASK(j1) { TASK(j1)
{
LOCK(r2); LOCK(r2);
JOB_REQUEST(j2); // job execution request for j2 JOB_REQUEST(j2); // job execution request for j2
if (state > 0) if (state > 0)
{
work(10); work(10);
}
else else
{
work(5); work(5);
}
/*
LOCK(r1); LOCK(r1);
#ifdef enable_itm #ifdef enable_itm
trace_printf("j1_r1_locked, before job request j2\n"); trace_printf("j1_r1_locked, before job request j2\n");
...@@ -57,11 +64,11 @@ TASK(j1) { ...@@ -57,11 +64,11 @@ TASK(j1) {
trace_printf("j1_r1_locked, after job request j2\n"); trace_printf("j1_r1_locked, after job request j2\n");
#endif #endif
UNLOCK(r1); UNLOCK(r1);
*/
UNLOCK(r2); UNLOCK(r2);
} }
TASK(j2) { TASK(j2)
{
#ifdef enable_itm #ifdef enable_itm
trace_printf("j2_enter\n"); trace_printf("j2_enter\n");
#endif #endif
...@@ -75,14 +82,18 @@ TASK(j2) { ...@@ -75,14 +82,18 @@ TASK(j2) {
#endif #endif
} }
int main() { int main()
{
#ifdef enable_itm #ifdef enable_itm
trace_printf("\nInit\n"); trace_printf("\nInit\n");
#endif #endif
#ifndef KLEE #ifndef KLEE
dwt_enable();
DWT->CYCCNT = 0;
#ifndef KLEE_WCET #ifndef KLEE_WCET
SETPRIO(j1); // Set HW priorities SETPRIO(j1); // Set HW priorities
SETPRIO(j2); SETPRIO(j2);
SETPRIO(j3); SETPRIO(j3);
...@@ -96,17 +107,17 @@ int main() { ...@@ -96,17 +107,17 @@ int main() {
BREAKPOINT; BREAKPOINT;
while (1) ; while (1) ;
return 0; return 0;
/* The case when NOT running WCET benchmark nor KLEE-analysis */
#else #else
dwt_enable();
DWT->CYCCNT = 0;
event_count = 0;
TRACE_EVENT(S, j1); TRACE_EVENT(S, j1);
EXTI1_IRQHandler(); EXTI1_IRQHandler();
TRACE_EVENT(E, j1); TRACE_EVENT(E, j1);
#endif
finish_execution(); finish_execution();
terminate_execution(); terminate_execution();
#endif
#elif (JOB == 1) #elif (JOB == 1)
// check task 1 // check task 1
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment