# Subversion Repositoriesshark

Rev
/*
Step 1: Generation of the Shape of the hard periodic load
---------------------------------------------------------
Given the LENGTH.DAT file, we need to produce a random shape for the

The random shape is the limit of bandwith that a certain time can be
if the currently used bandwidth is higher than the limit.

The random shape is contained into the SHAPE.DAT file. The file contains
a sequence of numbers in the form: <time> <b>,
where <time> is the time in seconds to wich refers the threshold,
and <b> is the maximum bandwidth that can be used after <time>.
The data is ordered by time.
*/

#include <stdio.h>
#include <stdlib.h>

#define MAX_BANDWIDTH 0xFFFFFFFF

int x;
int x_total[1000], x_B[1000];

int main()
{
unsigned length;
unsigned i;
unsigned total;

scanf("%d",&length);

srand(time(0));

total = 0;
x=0;
while (total < length) {
i = rand()%90;  // percentage of use

x_total[x] = total;
x_B[x] = (MAX_BANDWIDTH/100)*i;

fprintf(stderr,"x=%6d B=%d\n", x_total[x], i);
x++;

total += rand()%30+5;
}

printf("%d\n",x+1);
for (i=0; i<x; i++) {
printf("%u %u\n",x_total[i], x_B[i]);
}

printf("%u 0\n",length);

return 0;
}