Subversion Repositories shark

Rev

Rev 1606 | 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
 
1606 tullio 18
/*
19
 * This program is free software; you can redistribute it and/or modify
20
 * it under the terms of the GNU General Public License as published by
21
 * the Free Software Foundation; either version 2 of the License, or
22
 * (at your option) any later version.
23
 *
24
 * This program is distributed in the hope that it will be useful,
25
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
27
 * GNU General Public License for more details.
28
 *
29
 * You should have received a copy of the GNU General Public License
30
 * along with this program; if not, write to the Free Software
31
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
32
 *
33
 */
34
 
1489 giacomo 35
/* The tracer instrumentation ideas come from the York PWCET analisys tool
36
 *     
37
 *      Real-Time System Group
38
 *      University of York
39
 *
40
 */
41
 
42
#include <kernel/kern.h>
1493 giacomo 43
#include <time.h>
1489 giacomo 44
#include <tracer.h>
45
 
1493 giacomo 46
#define PWCET_Automatic_Ipoint(a) TRACER_LOGEVENT(FTrace_EVT_ipoint,(a),0);
1490 giacomo 47
 
1493 giacomo 48
extern int instrumented_function();
1489 giacomo 49
 
1493 giacomo 50
TASK ext_call(void)
1489 giacomo 51
{
52
 
1493 giacomo 53
  while(1) {
1489 giacomo 54
 
1493 giacomo 55
    instrumented_function();
56
 
1490 giacomo 57
    task_testcancel();
1489 giacomo 58
    task_endcycle();
59
 
60
  }
61
 
62
  return 0;
63
 
64
}
65
 
1493 giacomo 66
#define TASKMAX 4
67
#define TASKDELAY 1000000
68
#define TASKDELAY_DELTA 100000
1489 giacomo 69
 
1493 giacomo 70
int exec_code() {
1489 giacomo 71
 
1493 giacomo 72
  int num;
73
  struct timespec t;
74
 
1489 giacomo 75
  HARD_TASK_MODEL m;
1493 giacomo 76
  PID p;
1489 giacomo 77
 
1493 giacomo 78
  clear();
1489 giacomo 79
 
1494 giacomo 80
  cprintf("Start");
1493 giacomo 81
 
1489 giacomo 82
  hard_task_default_model(m);
1493 giacomo 83
  hard_task_def_mit(m,200000 + rand() % 100000);
84
  hard_task_def_wcet(m,40000);
85
  hard_task_def_group(m,2);
1489 giacomo 86
 
1493 giacomo 87
  num = 0;
1489 giacomo 88
 
1493 giacomo 89
  while(num < TASKMAX) {
1489 giacomo 90
 
1494 giacomo 91
    cprintf(".");
92
 
1493 giacomo 93
    p = task_create("Instr",ext_call,&m,NULL);
94
    if (p == -1) {
95
      sys_shutdown_message("Could not create task <instr> ...");
1550 pj 96
      exit(1);
1489 giacomo 97
    }
98
 
1493 giacomo 99
    num++;
100
    task_activate(p);
1489 giacomo 101
 
1493 giacomo 102
    usleep(TASKDELAY + rand() % TASKDELAY_DELTA);
1489 giacomo 103
 
104
  }
105
 
106
  do {
107
    sys_gettime(&t);
1493 giacomo 108
  } while (t.tv_sec < 12);  
1489 giacomo 109
 
1493 giacomo 110
  cprintf("End\n");
1489 giacomo 111
 
1493 giacomo 112
  return 0;
113
 
1489 giacomo 114
}
115
 
1516 giacomo 116
extern unsigned int clk_per_msec;
117
 
1489 giacomo 118
int main(int argc, char **argv)
119
{
120
 
1508 giacomo 121
  int a,b,c,i;
1491 giacomo 122
  struct timespec t,start,end,diff;
1489 giacomo 123
 
124
  srand(sys_gettime(NULL));
125
 
126
  a = FTrace_chunk_create(1000000, 1000000, FTRACE_CHUNK_FLAG_FREE | FTRACE_CHUNK_FLAG_CYC);
127
  b = FTrace_chunk_create(1000000, 1000000, FTRACE_CHUNK_FLAG_FREE | FTRACE_CHUNK_FLAG_JTN);
128
  c = FTrace_chunk_create(1000000, 1000000, FTRACE_CHUNK_FLAG_FREE | FTRACE_CHUNK_FLAG_CYC);
129
 
130
  FTrace_chunk_link(a,b);
131
  FTrace_chunk_link(b,c);
132
 
1491 giacomo 133
  FTrace_actual_chunk_select(a);
134
 
1489 giacomo 135
  kern_gettime(&start);
136
  FTrace_enable();
137
 
1518 giacomo 138
  TRACER_LOGEVENT(FTrace_EVT_trace_start,proc_table[exec_shadow].context,clk_per_msec);
1510 giacomo 139
 
1508 giacomo 140
  for (i=0;i<10;i++)
141
        if (proc_table[i].context != 0) TRACER_LOGEVENT(FTrace_EVT_id,
142
                                                (unsigned short int)proc_table[i].context,i);
143
 
1493 giacomo 144
    exec_code();
1489 giacomo 145
 
146
  TRACER_LOGEVENT(FTrace_EVT_trace_stop,0,0);  
147
 
148
  FTrace_disable();
149
  kern_gettime(&end);
150
 
151
  SUBTIMESPEC(&end,&start,&diff);
152
 
153
  printf_xy(1,21,WHITE,"Logged Time %d s %d us",(int)diff.tv_sec,(int)diff.tv_nsec/1000);
154
 
1490 giacomo 155
  group_kill(2);
156
 
1491 giacomo 157
  do {
158
    sys_gettime(&t);
159
  } while (t.tv_sec < 12);
160
 
1494 giacomo 161
  FTrace_OSD_init_udp(1, "192.168.0.15", "192.168.0.12");
1490 giacomo 162
 
163
  FTrace_send_chunk(a, 0, FTRACE_CHUNK_FLAG_FREE | FTRACE_CHUNK_FLAG_CYC);
164
 
1489 giacomo 165
  return 0;
166
 
167
}
168