Subversion Repositories shark

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1085 pj 1
 
2
#include <netinet/in.h>
3
 
4
#include <stdlib.h>
5
#include <stdio.h>
6
#include "types.h"
7
#include <trace.h>
8
#include "util.h"
9
 
10
/* distribuzione del delta schedule_time - arrival_time */
11
 
12
#define MAXX 50
13
#define PREC 100
14
#define DELTA ((double)MAXX/(double)PREC)
15
 
16
#include "distr.c"
17
 
18
int task;
19
long a=-1;
20
long s;
21
 
22
int safunc(trc_event_t *ev)
23
{
24
  if (event_class(ev->event)!=TRC_CLASS_SYSTEM) return 0;
25
 
26
  if (ev->x.sys.task!=task) return 0;
27
 
28
  if (a==-1) {
29
    if (ev->event==TRC_ACTIVATE||ev->event==TRC_INTACTIVATION)
30
      a=ev->time;
31
  } else {
32
    if (ev->event==TRC_SCHEDULE) {
33
      s=ev->time;
34
      d_insert(s-a);
35
      a=-1;
36
    }    
37
  }
38
  return 0;
39
}
40
 
41
/* -- */
42
 
43
int main(int argc, char *argv[])
44
{
45
  int res;
46
 
47
  if (argc!=4) {
48
    fprintf(stderr,"usage: sa [tracefile] [pid] [outputfile]\n");
49
    return -1;
50
  }
51
 
52
  d_init();
53
 
54
  task=atoi(argv[2]);
55
  res=read_trace(argv[1],safunc);
56
 
57
  if (res==0) {
58
    FILE *fout;
59
    fout=fopen(argv[3],"wt");
60
    if (fout==NULL) {
61
      fprintf(stderr,"error writing output file!\n");
62
      return 0;
63
    }
64
    d_dump(fout);
65
    fclose(fout);
66
  }
67
 
68
  if (res!=0) {
69
    fprintf(stderr,"error=%i\n",res);
70
    perror("ERROR");
71
  }
72
 
73
  return 0;
74
}
75
 
76
 
77
 
78
 
79
 
80
 
81