Subversion Repositories shark

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1663 pj 1
/*
2
Step 1: Generation of the Shape of the hard periodic load
3
---------------------------------------------------------
4
Given the LENGTH.DAT file, we need to produce a random shape for the
5
Periodic load.
6
 
7
The random shape is the limit of bandwith that a certain time can be
8
available for creating hard tasks. Hard task creation is disabled
9
if the currently used bandwidth is higher than the limit.
10
 
11
The random shape is contained into the SHAPE.DAT file. The file contains
12
a sequence of numbers in the form: <time> <b>,
13
where <time> is the time in seconds to wich refers the threshold,
14
and <b> is the maximum bandwidth that can be used after <time>.
15
The data is ordered by time.
16
*/
17
 
18
#include <stdio.h>
19
#include <stdlib.h>
20
 
21
#define MAX_BANDWIDTH 0xFFFFFFFF
22
 
23
int x;
24
int x_total[1000], x_B[1000];
25
 
26
int main()
27
{
28
  unsigned length;
29
  unsigned i;
30
  unsigned total;
31
 
32
 
33
  scanf("%d",&length);
34
 
35
  srand(time(0));
36
 
37
 
38
  total = 0;
39
  x=0;
40
  while (total < length) {
41
    i = rand()%90;  // percentage of use
42
 
43
    x_total[x] = total;
44
    x_B[x] = (MAX_BANDWIDTH/100)*i;
45
 
46
    fprintf(stderr,"x=%6d B=%d\n", x_total[x], i);
47
    x++;
48
 
49
    total += rand()%30+5;
50
  }
51
 
52
  printf("%d\n",x+1);
53
  for (i=0; i<x; i++) {
54
      printf("%u %u\n",x_total[i], x_B[i]);
55
  }
56
 
57
  printf("%u 0\n",length);
58
 
59
  return 0;
60
}