Subversion Repositories shark

Rev

Rev 1491 | Rev 1494 | 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
 
1493 giacomo 63
  cprintf("Start\n");
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
 
1493 giacomo 74
    p = task_create("Instr",ext_call,&m,NULL);
75
    if (p == -1) {
76
      sys_shutdown_message("Could not create task <instr> ...");
77
      sys_end();
1489 giacomo 78
    }
79
 
1493 giacomo 80
    num++;
81
    task_activate(p);
1489 giacomo 82
 
1493 giacomo 83
    usleep(TASKDELAY + rand() % TASKDELAY_DELTA);
1489 giacomo 84
 
85
  }
86
 
87
  do {
88
    sys_gettime(&t);
1493 giacomo 89
  } while (t.tv_sec < 12);  
1489 giacomo 90
 
1493 giacomo 91
  cprintf("End\n");
1489 giacomo 92
 
1493 giacomo 93
  return 0;
94
 
1489 giacomo 95
}
96
 
97
int main(int argc, char **argv)
98
{
99
 
100
  int a,b,c;
1491 giacomo 101
  struct timespec t,start,end,diff;
1489 giacomo 102
 
103
  srand(sys_gettime(NULL));
104
 
105
  a = FTrace_chunk_create(1000000, 1000000, FTRACE_CHUNK_FLAG_FREE | FTRACE_CHUNK_FLAG_CYC);
106
  b = FTrace_chunk_create(1000000, 1000000, FTRACE_CHUNK_FLAG_FREE | FTRACE_CHUNK_FLAG_JTN);
107
  c = FTrace_chunk_create(1000000, 1000000, FTRACE_CHUNK_FLAG_FREE | FTRACE_CHUNK_FLAG_CYC);
108
 
109
  FTrace_chunk_link(a,b);
110
  FTrace_chunk_link(b,c);
111
 
1491 giacomo 112
  FTrace_actual_chunk_select(a);
113
 
1489 giacomo 114
  kern_gettime(&start);
115
  FTrace_enable();
116
 
117
  TRACER_LOGEVENT(FTrace_EVT_trace_start,0,0);
118
 
1493 giacomo 119
    exec_code();
1489 giacomo 120
 
121
  TRACER_LOGEVENT(FTrace_EVT_trace_stop,0,0);  
122
 
123
  FTrace_disable();
124
  kern_gettime(&end);
125
 
126
  SUBTIMESPEC(&end,&start,&diff);
127
 
128
  printf_xy(1,21,WHITE,"Logged Time %d s %d us",(int)diff.tv_sec,(int)diff.tv_nsec/1000);
129
 
1490 giacomo 130
  group_kill(2);
131
 
1491 giacomo 132
  do {
133
    sys_gettime(&t);
134
  } while (t.tv_sec < 12);
135
 
1493 giacomo 136
  FTrace_OSD_init_udp(1, "192.168.1.10", "192.168.1.1");
1490 giacomo 137
 
138
  FTrace_send_chunk(a, 0, FTRACE_CHUNK_FLAG_FREE | FTRACE_CHUNK_FLAG_CYC);
139
 
1489 giacomo 140
  return 0;
141
 
142
}
143