Subversion Repositories shark

Rev

Rev 1497 | Rev 1500 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1494 giacomo 1
#include <stdio.h>
2
#include <stdlib.h>
1499 giacomo 3
#include <math.h>
4
#include <unistd.h>
1494 giacomo 5
 
6
#define MAXCONTEXT 100
7
#define MAXJOB 100000
8
 
9
#define INT_CTX 1
10
#define INT_PID 9999
11
#define PID_NO_DEF -1
12
 
1495 giacomo 13
#define BACKGROUND 0
14
#define PERIODICAL 1
15
#define INTERRUPT  2
16
 
1499 giacomo 17
#define DRAW_NUM 1000
18
 
1495 giacomo 19
struct ctx_exec {
1494 giacomo 20
        int ctx;
21
        unsigned long long dtsc;
22
        unsigned long long start;
23
};
24
 
1495 giacomo 25
struct ctx_to_pid {
1494 giacomo 26
        int ctx;
27
        int pid;
28
};
29
 
1495 giacomo 30
struct endcycle {
1494 giacomo 31
        int ctx;
32
        unsigned long long tsc;
33
};
34
 
35
void Error(int num) {
1495 giacomo 36
        printf("Finite-State machine error: %d\n",num);
1494 giacomo 37
        exit(2);
38
}
39
 
1495 giacomo 40
int context_total = 0,endcycle_total = 0,job_total = 0,exec_total = 0;
41
struct ctx_exec *exec_list;
42
struct ctx_to_pid *context_list;
43
struct endcycle *endcycle_list;
44
struct ctx_exec *job_list;
1494 giacomo 45
 
1497 giacomo 46
unsigned int clk_per_msec = 0;
47
 
1495 giacomo 48
unsigned long long log_start_tsc = 0;
49
unsigned long long log_end_tsc = 0;
1499 giacomo 50
unsigned long long total_dtsc = 0;
1495 giacomo 51
 
1499 giacomo 52
int draw_data[DRAW_NUM];
53
 
54
int gnuplot_clear() {
55
 
56
   int i;
57
 
58
   for (i=0;i<DRAW_NUM;i++)
59
     draw_data[i] = 0;
60
 
61
   return 0;
62
 
63
}
64
 
65
int gnuplot_draw(unsigned long long max_limit) {
66
 
67
   FILE *gnuplot_data, *gnuplot_command;
68
   int i;
69
 
70
   gnuplot_data = fopen("/tmp/pwcet_tmp","w");
71
   gnuplot_command = popen("gnuplot","w");
72
   fprintf(gnuplot_command,"plot \"%s\" using 1:2 with lines\n","/tmp/pwcet_tmp");
73
   fflush(gnuplot_command);
74
 
75
   for (i=0;i<DRAW_NUM;i++)
76
     fprintf(gnuplot_data,"%f\t%f\n",(double)i * (double)max_limit / (double)DRAW_NUM,(float)draw_data[i]);
77
 
78
   fclose(gnuplot_data);
79
 
80
   getchar();
81
   fclose(gnuplot_command);
82
 
83
   return 0;
84
 
85
}
86
 
1495 giacomo 87
int create_lists(char *filename) {
88
 
1494 giacomo 89
  FILE *input_file;
90
 
1495 giacomo 91
  int type,par1,par2,k,i,state;
92
 
1494 giacomo 93
  int current_context = 0;
1495 giacomo 94
  int current_exec = 0;
1494 giacomo 95
  int current_endcycle = 0;
96
 
1495 giacomo 97
  unsigned long long last_tsc, tsc;
1494 giacomo 98
 
1495 giacomo 99
  input_file = fopen(filename,"r");
1494 giacomo 100
 
1495 giacomo 101
  /* Memory alloc */
102
  exec_list = malloc(sizeof(struct ctx_exec) * MAXJOB);
103
  context_list = malloc(sizeof(struct ctx_to_pid) * MAXCONTEXT);
104
  endcycle_list = malloc(sizeof(struct endcycle) * MAXJOB);
1494 giacomo 105
 
1495 giacomo 106
  /* Finite-State machine
107
   *
108
   * FS-Machine states:
1494 giacomo 109
 
110
 
111
        1 - Context running
112
        2 - Interrupt running
113
 
114
        10 - End
115
 
1495 giacomo 116
   */
1494 giacomo 117
 
118
  for(i=0;i<MAXCONTEXT;i++) {
1495 giacomo 119
    context_list[i].ctx = 0;
120
    context_list[i].pid = PID_NO_DEF;
1494 giacomo 121
  }
122
 
123
  /* The start context + interrupt context */
1495 giacomo 124
  context_total = 2;
1494 giacomo 125
  current_context = 0;
126
  last_tsc = 0;
127
  context_list[0].ctx = 0;
128
  context_list[0].pid = PID_NO_DEF;
129
  context_list[1].ctx = INT_CTX;
130
  context_list[1].pid = INT_PID;
131
 
132
  state = 0;
133
 
134
  k = 0;
135
  while(!feof(input_file)) {
136
 
137
    fscanf(input_file,"%d %llu",&type,&tsc);
138
    k++;
139
 
140
    switch (type) {
141
 
142
        case 0:
143
        case 1:
144
 
145
                /* No par */
146
                break;
147
 
148
        case 2:
149
        case 3:
150
        case 4:
151
        case 6:
152
        case 7:
153
        case 8:
154
 
155
                /* 1 par */
156
                fscanf(input_file,"%d",&par1);
157
                break;
158
 
159
        case 5:
160
                /* 2 par */
161
                fscanf(input_file,"%d %d",&par1,&par2);
162
                break;
163
 
164
    }
165
 
166
    switch (type) {
167
 
168
        case 0:
169
                if (state != 0) Error(1);
170
                printf("EVT:Log starts at [%12llu]\n",tsc);
171
                last_tsc = tsc;
172
                log_start_tsc = tsc;
1495 giacomo 173
                exec_list[current_exec].start = tsc;
1494 giacomo 174
                state = 1;
175
                break;
176
 
177
        case 1:
178
                printf("EVT:Log   ends at [%12llu]\n",tsc);
1495 giacomo 179
                exec_list[current_exec].dtsc = tsc - last_tsc;
180
                exec_list[current_exec].ctx = current_context;
181
                current_exec++;
1494 giacomo 182
                last_tsc = tsc;
183
                log_end_tsc = tsc;
184
                state = 10;
185
                break;
186
 
187
        /* Int start */
188
        case 2:
189
                if (state == 0) Error(2);
1495 giacomo 190
                exec_list[current_exec].dtsc = tsc - last_tsc;
191
                exec_list[current_exec].ctx = current_context;
192
                current_exec++;
1494 giacomo 193
                last_tsc = tsc;
194
                current_context = INT_CTX;
1495 giacomo 195
                exec_list[current_exec].start = tsc;
1494 giacomo 196
                state = 2;
197
                break;
198
 
199
        /* Int end */
200
        case 3:
201
                if (state != 2) Error(3);              
1495 giacomo 202
                exec_list[current_exec].dtsc = tsc - last_tsc;
203
                exec_list[current_exec].ctx = current_context;
204
                current_exec++;
1494 giacomo 205
                last_tsc = tsc;
206
                current_context = par1;
207
 
1495 giacomo 208
                for (i=0;i<context_total;i++)
1494 giacomo 209
                        if (par1 == context_list[i].ctx) break;
1495 giacomo 210
                if (i == context_total) {
211
                        context_list[context_total].ctx = par1;
212
                        context_total++;
1494 giacomo 213
                }
214
 
1495 giacomo 215
                exec_list[current_exec].start = tsc;
1494 giacomo 216
                state = 1;
217
                break;
218
 
219
        /* Change ctx */
220
        case 4:
221
 
1495 giacomo 222
                exec_list[current_exec].dtsc = tsc - last_tsc;
223
                exec_list[current_exec].ctx = current_context;
224
                current_exec++;
1494 giacomo 225
                last_tsc = tsc;
226
                current_context = par1;
227
 
1495 giacomo 228
                for (i=0;i<context_total;i++)
1494 giacomo 229
                        if (par1 == context_list[i].ctx) break;
1495 giacomo 230
                if (i == context_total) {
231
                        context_list[context_total].ctx = par1;
232
                        context_total++;
1494 giacomo 233
                }
234
 
1495 giacomo 235
                exec_list[current_exec].start = tsc;
1494 giacomo 236
                state = 1;
237
                break;
238
 
239
        /* Task create */
240
        case 5:
241
 
1495 giacomo 242
                for (i=0;i<context_total;i++)
1494 giacomo 243
                        if (par1 == context_list[i].ctx) break;
1495 giacomo 244
                if (i == context_total) {
245
                        context_list[context_total].ctx = par1;
246
                        context_list[context_total].pid = par2;
247
                        context_total++;
1494 giacomo 248
                }
249
 
250
                break;
251
 
252
        /* Task endcycle */
253
        case 8:
254
 
1495 giacomo 255
                for (i=0;i<context_total;i++)
1494 giacomo 256
                        if (par1 == context_list[i].ctx) break;
1495 giacomo 257
                if (i == context_total) Error(4);
1494 giacomo 258
 
259
                endcycle_list[current_endcycle].ctx = par1;
260
                endcycle_list[current_endcycle].tsc = tsc;
261
                current_endcycle++;
262
 
263
                break;
264
 
265
    }
266
 
1495 giacomo 267
    if (current_exec == MAXJOB-1) {
268
        printf("Too many execs...\n");
1494 giacomo 269
        exit(3);
270
    }
271
 
272
    if (current_endcycle == MAXJOB-1) {
273
        printf("Too many endcycle...\n");
274
        exit(4);
275
    }
276
 
277
    if (state == 10) break;
278
 
279
  }
280
 
1495 giacomo 281
  endcycle_total = current_endcycle;
282
  exec_total = current_exec;
1494 giacomo 283
 
1495 giacomo 284
  return k;
1494 giacomo 285
 
1495 giacomo 286
}
1494 giacomo 287
 
1495 giacomo 288
int create_job_list() {
1494 giacomo 289
 
1495 giacomo 290
  int current_job = 0, h, i, k;
291
  int temp_ctx;
292
  unsigned long long temp_tsc, endcycle_start_tsc;
293
  unsigned long long endcycle_end_tsc;
1494 giacomo 294
 
1495 giacomo 295
  job_list = malloc(sizeof(struct ctx_exec) * MAXJOB);
1494 giacomo 296
 
1495 giacomo 297
  for (k=0;k<context_total;k++) {
1494 giacomo 298
 
1495 giacomo 299
    temp_ctx = context_list[k].ctx;
300
    endcycle_start_tsc = 0;
1494 giacomo 301
 
1495 giacomo 302
    for (h=0;h<endcycle_total;h++) {
1494 giacomo 303
 
1495 giacomo 304
      if (endcycle_list[h].ctx == temp_ctx) {
1494 giacomo 305
 
1495 giacomo 306
        if (endcycle_start_tsc == 0)
307
          endcycle_start_tsc = log_start_tsc;
1494 giacomo 308
 
309
        endcycle_end_tsc = endcycle_list[h].tsc;
310
        temp_tsc = 0;
311
 
1495 giacomo 312
        job_list[current_job].start = 0;
1494 giacomo 313
 
1495 giacomo 314
        for(i=0;i<exec_total;i++)
315
                if (exec_list[i].ctx == temp_ctx) {
316
                        if (exec_list[i].start < endcycle_end_tsc &&
317
                                exec_list[i].start >= endcycle_start_tsc) {
318
                                if (job_list[current_job].start == 0)
319
                                  job_list[current_job].start = exec_list[i].start;
320
                                temp_tsc += exec_list[i].dtsc;
1494 giacomo 321
                        }
322
                }
323
 
1495 giacomo 324
        job_list[current_job].dtsc = temp_tsc;
325
        job_list[current_job].ctx = temp_ctx;
326
        current_job++;
1494 giacomo 327
 
328
        endcycle_start_tsc = endcycle_end_tsc;
329
 
1495 giacomo 330
      }
1494 giacomo 331
 
1495 giacomo 332
    }
1494 giacomo 333
 
1495 giacomo 334
  }    
335
 
336
  job_total = current_job;
337
 
1494 giacomo 338
  return 0;
339
 
340
}
341
 
1495 giacomo 342
int elaborate_statistics(int num, int task_type) {
343
 
1499 giacomo 344
  int i,k,h;
1495 giacomo 345
  char pidstr[10];
1499 giacomo 346
  unsigned long long temp_tsc,max_tsc,min_tsc;
347
  unsigned long long last_start, delta_start, first_exec;
348
  unsigned long long max_limit;
1495 giacomo 349
 
350
  switch (context_list[num].pid) {
351
      case PID_NO_DEF:
352
        sprintf(pidstr,"NODEF");
353
        break;
354
      case INT_PID:
355
        sprintf(pidstr,"  INT");
356
        break;
357
      default:
358
        sprintf(pidstr,"%5d",context_list[num].pid);
359
        break;
360
  }
361
 
362
  if (task_type == BACKGROUND) {
363
 
364
    printf("Background Task CTX [%5d] PID [%s]\n",context_list[num].ctx,pidstr);
365
 
366
    temp_tsc = 0;
367
    max_tsc = 0;
1499 giacomo 368
    min_tsc = 0xFFFFFFFF;
369
    first_exec = 0;
1495 giacomo 370
    k = 0;
371
    for (i=0;i<exec_total;i++)
372
      if (exec_list[i].ctx == context_list[num].ctx) {
1499 giacomo 373
        if (first_exec == 0) first_exec = exec_list[i].start - log_start_tsc;
1495 giacomo 374
        if (exec_list[i].dtsc > max_tsc) max_tsc = exec_list[i].dtsc;
1499 giacomo 375
        if (exec_list[i].dtsc < min_tsc) min_tsc = exec_list[i].dtsc;
1495 giacomo 376
        temp_tsc += exec_list[i].dtsc;
377
        k++;
378
      }
1497 giacomo 379
    printf("  Total Execution dTSC [%12llu] us [%12llu]\n",temp_tsc,temp_tsc*1000/clk_per_msec);
1499 giacomo 380
    printf("  Mean  CPU Bandwidth  [%11f%c]\n",(double)(temp_tsc)/(double)(total_dtsc)*100.0,'%');
381
    printf("    after first exec   [%11f%c]\n",(double)(temp_tsc)/(double)(total_dtsc-first_exec)*100.0,'%');
1495 giacomo 382
    printf("  Execs Number         [%12d]\n",k);
1499 giacomo 383
    printf("  Min  Exec       dTSC [%12llu] us [%12llu]\n",min_tsc, min_tsc*1000/clk_per_msec);
1497 giacomo 384
    printf("  Mean Exec       dTSC [%12llu] us [%12llu]\n",temp_tsc / k, temp_tsc / k*1000/clk_per_msec);
385
    printf("  Max  Exec       dTSC [%12llu] us [%12llu]\n\n",max_tsc, max_tsc*1000/clk_per_msec);
1495 giacomo 386
 
387
  }
388
 
389
  if (task_type == INTERRUPT) {
390
 
391
    printf("Interrupts\n");
392
 
393
    temp_tsc = 0;
394
    max_tsc = 0;
1499 giacomo 395
    min_tsc = 0xFFFFFFFF;
396
    first_exec = 0;
1495 giacomo 397
    k = 0;
398
    for (i=0;i<exec_total;i++)
399
      if (exec_list[i].ctx == context_list[num].ctx) {
1499 giacomo 400
        if (first_exec == 0) first_exec = exec_list[i].start - log_start_tsc;
1495 giacomo 401
        if (exec_list[i].dtsc > max_tsc) max_tsc = exec_list[i].dtsc;
1499 giacomo 402
        if (exec_list[i].dtsc < min_tsc) min_tsc = exec_list[i].dtsc;
1495 giacomo 403
        temp_tsc += exec_list[i].dtsc;
404
        k++;
405
      }
1499 giacomo 406
 
407
    gnuplot_clear();
408
 
409
    max_limit = max_tsc*1000/clk_per_msec;
410
 
1497 giacomo 411
    printf("  Total Execution dTSC [%12llu] us [%12llu]\n",temp_tsc,temp_tsc*1000/clk_per_msec);
1499 giacomo 412
    printf("  Mean  CPU Bandwidth  [%11f%c]\n",(double)(temp_tsc)/(double)(total_dtsc)*100.0,'%');
413
    printf("    after first int    [%11f%c]\n",(double)(temp_tsc)/(double)(total_dtsc-first_exec)*100.0,'%');
1495 giacomo 414
    printf("  Interrupts Number    [%12d]\n",k);
1499 giacomo 415
    printf("  Min  Interrupt  dTSC [%12llu] us [%12llu]\n",min_tsc,min_tsc*1000/clk_per_msec);
1497 giacomo 416
    printf("  Mean Interrupt  dTSC [%12llu] us [%12llu]\n",temp_tsc / k,temp_tsc / k*1000/clk_per_msec);
417
    printf("  Max  Interrupt  dTSC [%12llu] us [%12llu]\n\n",max_tsc,max_tsc*1000/clk_per_msec);
1495 giacomo 418
 
1499 giacomo 419
    for (i=0;i<exec_total;i++)
420
      if (exec_list[i].ctx == context_list[num].ctx) {
421
        h = (exec_list[i].dtsc*1000/clk_per_msec) * DRAW_NUM / max_limit;
422
        if (h < DRAW_NUM) draw_data[h]++;
423
      }
424
 
425
    gnuplot_draw(max_limit);
426
 
1496 giacomo 427
    last_start = 0;
428
    temp_tsc = 0;
429
    max_tsc = 0;
1499 giacomo 430
    min_tsc = 0xFFFFFFFF;
1496 giacomo 431
    k = 0;
432
    for (i=0;i<exec_total;i++)
433
      if (exec_list[i].ctx == context_list[num].ctx) {
434
        if (last_start == 0) {
435
                last_start = exec_list[i].start;
436
        } else {
437
                delta_start = exec_list[i].start - last_start;
438
                if (delta_start > max_tsc) max_tsc = delta_start;
1499 giacomo 439
                if (delta_start < min_tsc) min_tsc = delta_start;
1496 giacomo 440
                temp_tsc += delta_start;
441
                k++;
442
                last_start = exec_list[i].start;
443
        }
444
      }
445
 
1499 giacomo 446
    printf("  Min  Arr. Delta dTSC [%12llu] us [%12llu]\n",min_tsc,min_tsc*1000/clk_per_msec);
1497 giacomo 447
    printf("  Mean Arr. Delta dTSC [%12llu] us [%12llu]\n",temp_tsc / k,temp_tsc / k*1000/clk_per_msec);
448
    printf("  Max  Arr. Delta dTSC [%12llu] us [%12llu]\n\n",max_tsc,max_tsc*1000/clk_per_msec);
1496 giacomo 449
 
1499 giacomo 450
    gnuplot_clear();
451
 
452
    max_limit = max_tsc*1000/clk_per_msec;
453
 
454
    last_start = 0;
455
    for (i=0;i<exec_total;i++)
456
      if (exec_list[i].ctx == context_list[num].ctx) {
457
        if (last_start == 0) {
458
                last_start = exec_list[i].start;
459
        } else {
460
                delta_start = exec_list[i].start - last_start;
461
 
462
                h = (delta_start*1000/clk_per_msec) * DRAW_NUM / max_limit;
463
                if (h < DRAW_NUM) draw_data[h]++;
464
 
465
                last_start = exec_list[i].start;
466
        }
467
      }
468
 
469
    gnuplot_draw(max_limit);
470
 
1495 giacomo 471
  }
472
 
473
  if (task_type == PERIODICAL) {
474
 
475
    printf("Periodical Task CTX [%5d] PID [%s]\n",context_list[num].ctx,pidstr);    
476
 
477
    temp_tsc = 0;
478
    max_tsc = 0;
1499 giacomo 479
    min_tsc = 0xFFFFFFFF;
480
    first_exec = 0;
1495 giacomo 481
    k = 0;
482
    for (i=0;i<exec_total;i++)
483
      if (exec_list[i].ctx == context_list[num].ctx) {
1499 giacomo 484
        if (first_exec == 0) first_exec = exec_list[i].start - log_start_tsc;
1495 giacomo 485
        if (exec_list[i].dtsc > max_tsc) max_tsc = exec_list[i].dtsc;
1499 giacomo 486
        if (exec_list[i].dtsc < min_tsc) min_tsc = exec_list[i].dtsc;
1495 giacomo 487
        temp_tsc += exec_list[i].dtsc;
488
        k++;
489
      }
1497 giacomo 490
    printf("  Total Execution dTSC [%12llu] us [%12llu]\n",temp_tsc,temp_tsc*1000/clk_per_msec);
1499 giacomo 491
    printf("  Mean  CPU Bandwidth  [%11f%c]\n",(double)(temp_tsc)/(double)(total_dtsc)*100.0,'%');
492
    printf("    after first int    [%11f%c]\n",(double)(temp_tsc)/(double)(total_dtsc-first_exec)*100.0,'%');
1495 giacomo 493
    printf("  Execs Number         [%12d]\n",k);
1499 giacomo 494
    printf("  Min  Exec       dTSC [%12llu] us [%12llu]\n",min_tsc,min_tsc*1000/clk_per_msec);
1497 giacomo 495
    printf("  Mean Exec       dTSC [%12llu] us [%12llu]\n",temp_tsc / k,temp_tsc / k*1000/clk_per_msec);
496
    printf("  Max  Exec       dTSC [%12llu] us [%12llu]\n\n",max_tsc,max_tsc*1000/clk_per_msec);    
1495 giacomo 497
 
498
    temp_tsc = 0;
499
    max_tsc = 0;
1499 giacomo 500
    min_tsc = 0xFFFFFFFF;
1495 giacomo 501
    k = 0;
502
    for (i=0;i<job_total;i++)
503
      if (job_list[i].ctx == context_list[num].ctx) {
504
        if (job_list[i].dtsc > max_tsc) max_tsc = job_list[i].dtsc;
1499 giacomo 505
        if (job_list[i].dtsc < min_tsc) min_tsc = job_list[i].dtsc;
1495 giacomo 506
        temp_tsc += job_list[i].dtsc;
507
        k++;
508
      }
1497 giacomo 509
    printf("  Total Job Exec  dTSC [%12llu] us [%12llu]\n",temp_tsc,temp_tsc*1000/clk_per_msec);
1495 giacomo 510
    printf("  Jobs Number          [%12d]\n",k);
1499 giacomo 511
    printf("  Min  Job        dTSC [%12llu] us [%12llu]\n",min_tsc,min_tsc*1000/clk_per_msec);
1497 giacomo 512
    printf("  Mean Job        dTSC [%12llu] us [%12llu]\n",temp_tsc / k,temp_tsc / k*1000/clk_per_msec);
513
    printf("  Max  Job        dTSC [%12llu] us [%12llu]\n\n",max_tsc,max_tsc*1000/clk_per_msec);
1496 giacomo 514
 
1499 giacomo 515
    gnuplot_clear();
516
 
517
    max_limit = max_tsc*1000/clk_per_msec;
518
 
519
    for (i=0;i<job_total;i++)
520
      if (job_list[i].ctx == context_list[num].ctx) {
521
        h = (job_list[i].dtsc*1000/clk_per_msec) * DRAW_NUM / max_limit;
522
        if (h < DRAW_NUM) draw_data[h]++;
523
      }
524
 
525
    gnuplot_draw(max_limit);
526
 
1496 giacomo 527
    last_start = 0;
528
    temp_tsc = 0;
529
    max_tsc = 0;
1499 giacomo 530
    min_tsc = 0xFFFFFFFF;
1496 giacomo 531
    k = 0;
532
    for (i=0;i<job_total;i++)
533
      if (job_list[i].ctx == context_list[num].ctx) {
534
        if (last_start == 0) {
535
                last_start = job_list[i].start;
536
        } else {
537
                delta_start = job_list[i].start - last_start;
538
                if (delta_start > max_tsc) max_tsc = delta_start;
1499 giacomo 539
                if (delta_start < min_tsc) min_tsc = delta_start;
1496 giacomo 540
                temp_tsc += delta_start;
541
                k++;
542
                last_start = job_list[i].start;
543
        }
544
      }
1499 giacomo 545
 
546
    printf("  Min  Arr. Delta dTSC [%12llu] us [%12llu]\n\n",min_tsc,min_tsc*1000/clk_per_msec);
1497 giacomo 547
    printf("  Mean Arr. Delta dTSC [%12llu] us [%12llu]\n",temp_tsc / k,temp_tsc / k*1000/clk_per_msec);
548
    printf("  Max  Arr. Delta dTSC [%12llu] us [%12llu]\n\n",max_tsc,max_tsc*1000/clk_per_msec);
1495 giacomo 549
 
1499 giacomo 550
    gnuplot_clear();
551
 
552
    max_limit = max_tsc*1000/clk_per_msec;
553
 
554
    last_start = 0;
555
    for (i=0;i<job_total;i++)
556
      if (job_list[i].ctx == context_list[num].ctx) {
557
        if (last_start == 0) {
558
                last_start = job_list[i].start;
559
        } else {
560
                delta_start = job_list[i].start - last_start;
561
 
562
                h = (delta_start*1000/clk_per_msec) * DRAW_NUM / max_limit;
563
                if (h < DRAW_NUM) draw_data[h]++;
564
 
565
                last_start = exec_list[i].start;
566
        }
567
      }
568
 
569
    gnuplot_draw(max_limit);
570
 
1495 giacomo 571
  }
572
 
573
  return 0;
574
 
575
}
576
 
577
int main(int argc, char *argv[]) {
578
 
579
  int events_total,k,i;
580
  int task_type;
581
  unsigned long long total_tsc;
582
 
1497 giacomo 583
  if (argc < 3) {
584
    printf("%s: Enter the input file name and clk_per_msec [%s filename clk_per_msec]\n",argv[0],argv[0]);
1495 giacomo 585
    exit(1);
586
  }
587
 
588
  printf("\n");
1497 giacomo 589
 
590
  clk_per_msec = atoi(argv[2]);
591
 
592
  printf("Clk/msec = %u\n\n",clk_per_msec);
593
 
1495 giacomo 594
  events_total = create_lists(argv[1]);
595
 
1499 giacomo 596
  total_dtsc = log_end_tsc - log_start_tsc;
1495 giacomo 597
 
1499 giacomo 598
  printf("\nTotal dTSC [%12llu] us [%12llu]\n", total_dtsc, total_dtsc*1000/clk_per_msec);
599
  printf("Events     [%12d]\n",events_total);
600
  printf("Execs      [%12d]\n",exec_total);
601
  printf("EndCycles  [%12d]\n",endcycle_total);
602
 
1495 giacomo 603
  total_tsc = 0;
604
  for (i=0;i<exec_total;i++)
605
        total_tsc += exec_list[i].dtsc;
606
 
607
  /* Exec total execution check */
608
  printf("\nExec TSC sum = %llu (%2.2f)\n",total_tsc,(float)total_tsc/((float)(log_end_tsc - log_start_tsc))*100.0);
609
 
610
  printf("\nPreemption Removing.... \n");
611
 
612
  /* Remove preemption from the computation time */
613
  create_job_list();
614
 
615
  for (k=0;k<job_total;k++)
616
        printf("Job CTX [%5d] Start [%12llu] dTSC [%12llu]\n",
617
                job_list[k].ctx,job_list[k].start,job_list[k].dtsc);
618
 
619
  printf("\nCompute Task Statistics.... \n\n");
620
 
621
  for (i=0;i<context_total;i++) {
622
 
623
        task_type = BACKGROUND;
624
 
625
        if (context_list[i].ctx == INT_CTX) task_type = INTERRUPT;
626
 
627
        for (k=0;k<job_total;k++)
628
                if (job_list[k].ctx == context_list[i].ctx) {
629
                  task_type = PERIODICAL;
630
                  break;
631
                }
632
 
633
        elaborate_statistics(i,task_type);
634
 
635
  }
1499 giacomo 636
 
1495 giacomo 637
  return 0;
638
 
639
}
640