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 1 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 1. At time 2, an
update from stream 1 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 1), this update is selected and the age of stream 1 is reset to
zero.
At time 3, no new updates arrive and therefore the queue remains empty. The age of each steam is
incremented by 1. Note that stream 1's age, which has been reset to zero at time 2, is now 1. On the
other hand, the ages of streams 2 and 3 are now 3. At time 4, new updates arrive from both streams 1
and 2 and are placed in the queue (indicated by the *'s). Since stream 2's age is higher than stream 1's,
the pending update from stream 2 is selected by the server and stream 2's age is reset to zero.
And so on ...
In your program, assume that there are a maximum of 100 data streams:
#define MAX_STREAMS 100
Implement a data stream as a struct with the appropriate members, e.g.,
typedef struct {
int id; // ID
int period; // period
int last_update_time; // time of last update
int pending_upd\bar (a) te; //1 if pending update is in queue; else 0
int age; // age
int age_sum; // sum of ages from time 1 to current time
} DataStream;
The data streams can then be implemented as an array of structs, each of type DataStream:
DataStream streams[MAX_STREAMS];
Write a C program that implements the

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!