Subversion Repositories shark

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1655 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
 *   Paolo Gai           <pj@gandalf.sssup.it>
10
 *   Massimiliano Giorgi <massy@gandalf.sssup.it>
11
 *   Luca Abeni          <luca@gandalf.sssup.it>
12
 *   (see the web pages for full authors list)
13
 *
14
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
15
 *
16
 * http://www.sssup.it
17
 * http://retis.sssup.it
18
 * http://shark.sssup.it
19
 */
20
 
21
/*
22
 * Copyright (C) 2000 Massimiliano Giorgi
23
 *
24
 * This program is free software; you can redistribute it and/or modify
25
 * it under the terms of the GNU General Public License as published by
26
 * the Free Software Foundation; either version 2 of the License, or
27
 * (at your option) any later version.
28
 *
29
 * This program is distributed in the hope that it will be useful,
30
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
31
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
32
 * GNU General Public License for more details.
33
 *
34
 * You should have received a copy of the GNU General Public License
35
 * along with this program; if not, write to the Free Software
36
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
37
 *
38
 * CVS :        $Id: sa.c,v 1.1.1.1 2004-05-24 18:03:44 giacomo Exp $
39
 */
40
 
41
#include <netinet/in.h>
42
 
43
#include <stdlib.h>
44
#include <stdio.h>
45
#include "types.h"
46
#include <trace.h>
47
#include "util.h"
48
 
49
/* this file prints the distribution of (schedule_time - arrival_time) */
50
 
51
#define MAXX 50
52
#define PREC 100
53
#define DELTA ((double)MAXX/(double)PREC)
54
 
55
#include "distr.c"
56
 
57
int task;
58
long a=-1;
59
long s;
60
 
61
int safunc(trc_event_t *ev)
62
{
63
  if (event_class(ev->event)!=TRC_CLASS_SYSTEM) return 0;
64
 
65
  if (ev->x.sys.task!=task) return 0;
66
 
67
  if (a==-1) {
68
    if (ev->event==TRC_ACTIVATE||ev->event==TRC_INTACTIVATION)
69
      a=ev->time;
70
  } else {
71
    if (ev->event==TRC_SCHEDULE) {
72
      s=ev->time;
73
      d_insert(s-a);
74
      a=-1;
75
    }    
76
  }
77
  return 0;
78
}
79
 
80
/* -- */
81
 
82
int main(int argc, char *argv[])
83
{
84
  int res;
85
 
86
  if (argc!=4) {
87
    fprintf(stderr,"usage: sa [tracefile] [pid] [outputfile]\n");
88
    return -1;
89
  }
90
 
91
  d_init();
92
 
93
  task=atoi(argv[2]);
94
  res=read_trace(argv[1],safunc);
95
 
96
  if (res==0) {
97
    FILE *fout;
98
    fout=fopen(argv[3],"wt");
99
    if (fout==NULL) {
100
      fprintf(stderr,"error writing output file!\n");
101
      return 0;
102
    }
103
    d_dump(fout);
104
    fclose(fout);
105
  }
106
 
107
  if (res!=0) {
108
    fprintf(stderr,"error=%i\n",res);
109
    perror("ERROR");
110
  }
111
 
112
  return 0;
113
}
114
 
115
 
116
 
117
 
118
 
119
 
120