Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1085 | pj | 1 | |
2 | #include <stdio.h> |
||
3 | #include <stdlib.h> |
||
4 | #include "types.h" |
||
5 | #include <trace.h> |
||
6 | #include "util.h" |
||
7 | |||
8 | /* distribuzione dei tempi di attesa sulle richieste al disco */ |
||
9 | |||
10 | #define MAXX 37000 |
||
11 | #define PREC 37000 |
||
12 | #define DELTA ((double)MAXX/(double)PREC) |
||
13 | |||
14 | #include "distr.c" |
||
15 | |||
16 | int task; |
||
17 | long a=-1; |
||
18 | |||
19 | int waitfunc(trc_event_t *ev) |
||
20 | { |
||
21 | if (event_class(ev->event)!=TRC_CLASS_USER) return 0; |
||
22 | if (ev->x.usr.n!=task) return 0; |
||
23 | if (ev->event==TRC_USER1) { |
||
24 | a=ev->time; |
||
25 | return 0; |
||
26 | } |
||
27 | if (ev->event==TRC_USER2) { |
||
28 | if (a!=-1) d_insert(ev->time-a); |
||
29 | a=-1; |
||
30 | } |
||
31 | return 0; |
||
32 | } |
||
33 | |||
34 | int main(int argc, char *argv[]) |
||
35 | { |
||
36 | FILE *fout; |
||
37 | int res; |
||
38 | if (argc!=4) { |
||
39 | fprintf(stderr,"missing filename!\n"); |
||
40 | return -1; |
||
41 | } |
||
42 | d_init(); |
||
43 | task=atoi(argv[2]); |
||
44 | res=read_trace(argv[1],waitfunc); |
||
45 | if (res==0) { |
||
46 | fout=fopen(argv[3],"wt"); |
||
47 | if (fout!=NULL) { |
||
48 | d_dump(fout); |
||
49 | fclose(fout); |
||
50 | } else |
||
51 | fprintf(stderr,"can't create output file!\n"); |
||
52 | } else |
||
53 | fprintf(stderr,"read_trace error\n"); |
||
54 | |||
55 | return 0; |
||
56 | } |