Subversion Repositories shark

Rev

Rev 1518 | 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> ...");
1550 pj 79
      exit(1);
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
 
1516 giacomo 99
extern unsigned int clk_per_msec;
100
 
1489 giacomo 101
int main(int argc, char **argv)
102
{
103
 
1508 giacomo 104
  int a,b,c,i;
1491 giacomo 105
  struct timespec t,start,end,diff;
1489 giacomo 106
 
107
  srand(sys_gettime(NULL));
108
 
109
  a = FTrace_chunk_create(1000000, 1000000, FTRACE_CHUNK_FLAG_FREE | FTRACE_CHUNK_FLAG_CYC);
110
  b = FTrace_chunk_create(1000000, 1000000, FTRACE_CHUNK_FLAG_FREE | FTRACE_CHUNK_FLAG_JTN);
111
  c = FTrace_chunk_create(1000000, 1000000, FTRACE_CHUNK_FLAG_FREE | FTRACE_CHUNK_FLAG_CYC);
112
 
113
  FTrace_chunk_link(a,b);
114
  FTrace_chunk_link(b,c);
115
 
1491 giacomo 116
  FTrace_actual_chunk_select(a);
117
 
1489 giacomo 118
  kern_gettime(&start);
119
  FTrace_enable();
120
 
1518 giacomo 121
  TRACER_LOGEVENT(FTrace_EVT_trace_start,proc_table[exec_shadow].context,clk_per_msec);
1510 giacomo 122
 
1508 giacomo 123
  for (i=0;i<10;i++)
124
        if (proc_table[i].context != 0) TRACER_LOGEVENT(FTrace_EVT_id,
125
                                                (unsigned short int)proc_table[i].context,i);
126
 
1493 giacomo 127
    exec_code();
1489 giacomo 128
 
129
  TRACER_LOGEVENT(FTrace_EVT_trace_stop,0,0);  
130
 
131
  FTrace_disable();
132
  kern_gettime(&end);
133
 
134
  SUBTIMESPEC(&end,&start,&diff);
135
 
136
  printf_xy(1,21,WHITE,"Logged Time %d s %d us",(int)diff.tv_sec,(int)diff.tv_nsec/1000);
137
 
1490 giacomo 138
  group_kill(2);
139
 
1491 giacomo 140
  do {
141
    sys_gettime(&t);
142
  } while (t.tv_sec < 12);
143
 
1494 giacomo 144
  FTrace_OSD_init_udp(1, "192.168.0.15", "192.168.0.12");
1490 giacomo 145
 
146
  FTrace_send_chunk(a, 0, FTRACE_CHUNK_FLAG_FREE | FTRACE_CHUNK_FLAG_CYC);
147
 
1489 giacomo 148
  return 0;
149
 
150
}
151