Question: Write a C program that implements the aforementioned algorithm for minimizing AoI. Specifically, the program should prompt the user for the number of data streams,
Write a C program that implements the aforementioned algorithm for minimizing AoI. Specifically, the
program should prompt the user for the number of data streams, the period of each stream, and the
simulation time The program should then print, for each time step between and :
a the age of each stream;
b any pending update in the queue for each stream; and
c the stream whose update is selected by the server at this time step.
The outputs for a and b should be their values before the server selects the stream in c and updates
updates arrive or are processed; therefore, the age of each stream is incremented by At time an
update from stream arrives and is placed in the queue the indicates this pending update At this
point, the server selects the pending update in the queue from the stream with the oldest age. As there
is only one pending update from stream this update is selected and the age of stream is reset to
zero.
At time no new updates arrive and therefore the queue remains empty. The age of each steam is
incremented by Note that stream s age, which has been reset to zero at time is now On the
other hand, the ages of streams and are now At time new updates arrive from both streams
and and are placed in the queue indicated by the s Since stream s age is higher than stream s
the pending update from stream is selected by the server and stream s age is reset to zero.
And so on
In your program, assume that there are a maximum of data streams:
#define MAXSTREAMS
Implement a data stream as a struct with the appropriate members, eg
typedef struct
int id; ID
int period; period
int lastupdatetime; time of last update
int pendingupdbar a te; if pending update is in queue; else
int age; age
int agesum; sum of ages from time to current time
DataStream;
The data streams can then be implemented as an array of structs, each of type DataStream:
DataStream streamsMAXSTREAMS;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
