Subversion Repositories shark

Rev

Rev 1493 | Rev 1508 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1489 giacomo 1
/*
2
 * Project: S.Ha.R.K.
3
 *
4
 * Coordinators:
5
 *   Giorgio Buttazzo    <giorgio@sssup.it>
6
 *   Paolo Gai           <pj@gandalf.sssup.it>
7
 *
8
 * Authors     :
9
 *   Giacomo Guidi       <giacomo@gandalf.sssup.it>
10
 *
11
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
12
 *
13
 * http://www.sssup.it
14
 * http://retis.sssup.it
15
 * http://shark.sssup.it
16
 */
17
 
18
/* The tracer instrumentation ideas come from the York PWCET analisys tool
19
 *     
20
 *      Real-Time System Group
21
 *      University of York
22
 *
23
 */
24
 
25
#include <kernel/kern.h>
1493 giacomo 26
#include <time.h>
1489 giacomo 27
#include <tracer.h>
28
 
1493 giacomo 29
#define PWCET_Automatic_Ipoint(a) TRACER_LOGEVENT(FTrace_EVT_ipoint,(a),0);
1490 giacomo 30
 
1493 giacomo 31
extern int instrumented_function();
1489 giacomo 32
 
1493 giacomo 33
TASK ext_call(void)
1489 giacomo 34
{
35
 
1493 giacomo 36
  while(1) {
1489 giacomo 37
 
1493 giacomo 38
    instrumented_function();
39
 
1490 giacomo 40
    task_testcancel();
1489 giacomo 41
    task_endcycle();
42
 
43
  }
44
 
45
  return 0;
46
 
47
}
48
 
1493 giacomo 49
#define TASKMAX 4
50
#define TASKDELAY 1000000
51
#define TASKDELAY_DELTA 100000
1489 giacomo 52
 
1493 giacomo 53
int exec_code() {
1489 giacomo 54
 
1493 giacomo 55
  int num;
56
  struct timespec t;
57
 
1489 giacomo 58
  HARD_TASK_MODEL m;
1493 giacomo 59
  PID p;
1489 giacomo 60
 
1493 giacomo 61
  clear();
1489 giacomo 62
 
1494 giacomo 63
  cprintf("Start");
1493 giacomo 64
 
1489 giacomo 65
  hard_task_default_model(m);
1493 giacomo 66
  hard_task_def_mit(m,200000 + rand() % 100000);
67
  hard_task_def_wcet(m,40000);
68
  hard_task_def_group(m,2);
1489 giacomo 69
 
1493 giacomo 70
  num = 0;
1489 giacomo 71
 
1493 giacomo 72
  while(num < TASKMAX) {
1489 giacomo 73
 
1494 giacomo 74
    cprintf(".");
75
 
1493 giacomo 76
    p = task_create("Instr",ext_call,&m,NULL);
77
    if (p == -1) {
78
      sys_shutdown_message("Could not create task <instr> ...");
79
      sys_end();
1489 giacomo 80
    }
81
 
1493 giacomo 82
    num++;
83
    task_activate(p);
1489 giacomo 84
 
1493 giacomo 85
    usleep(TASKDELAY + rand() % TASKDELAY_DELTA);
1489 giacomo 86
 
87
  }
88
 
89
  do {
90
    sys_gettime(&t);
1493 giacomo 91
  } while (t.tv_sec < 12);  
1489 giacomo 92
 
1493 giacomo 93
  cprintf("End\n");
1489 giacomo 94
 
1493 giacomo 95
  return 0;
96
 
1489 giacomo 97
}
98
 
99
int main(int argc, char **argv)
100
{
101
 
102
  int a,b,c;
1491 giacomo 103
  struct timespec t,start,end,diff;
1489 giacomo 104
 
105
  srand(sys_gettime(NULL));
106
 
107
  a = FTrace_chunk_create(1000000, 1000000, FTRACE_CHUNK_FLAG_FREE | FTRACE_CHUNK_FLAG_CYC);
108
  b = FTrace_chunk_create(1000000, 1000000, FTRACE_CHUNK_FLAG_FREE | FTRACE_CHUNK_FLAG_JTN);
109
  c = FTrace_chunk_create(1000000, 1000000, FTRACE_CHUNK_FLAG_FREE | FTRACE_CHUNK_FLAG_CYC);
110
 
111
  FTrace_chunk_link(a,b);
112
  FTrace_chunk_link(b,c);
113
 
1491 giacomo 114
  FTrace_actual_chunk_select(a);
115
 
1489 giacomo 116
  kern_gettime(&start);
117
  FTrace_enable();
118
 
119
  TRACER_LOGEVENT(FTrace_EVT_trace_start,0,0);
120
 
1493 giacomo 121
    exec_code();
1489 giacomo 122
 
123
  TRACER_LOGEVENT(FTrace_EVT_trace_stop,0,0);  
124
 
125
  FTrace_disable();
126
  kern_gettime(&end);
127
 
128
  SUBTIMESPEC(&end,&start,&diff);
129
 
130
  printf_xy(1,21,WHITE,"Logged Time %d s %d us",(int)diff.tv_sec,(int)diff.tv_nsec/1000);
131
 
1490 giacomo 132
  group_kill(2);
133
 
1491 giacomo 134
  do {
135
    sys_gettime(&t);
136
  } while (t.tv_sec < 12);
137
 
1494 giacomo 138
  FTrace_OSD_init_udp(1, "192.168.0.15", "192.168.0.12");
1490 giacomo 139
 
140
  FTrace_send_chunk(a, 0, FTRACE_CHUNK_FLAG_FREE | FTRACE_CHUNK_FLAG_CYC);
141
 
1489 giacomo 142
  return 0;
143
 
144
}
145