Write a scheduler for a simple-minded file server that can handle only one request at a time. The requests to the server are simulated by the entries in a file. Each entry consists of these elements (with an example shown below)
Arrival Priority IP Address Length of service 325 6 144.80.128.59 33
Time at the server is just a counter, measuring in seconds from the time the server started - this request comes in 325 seconds after the server is started. The priority is an integer number between 1 and 20 - the higher the number, the more important the request. IP addresses are dot-separated number strings as illustrated. The length of service is the number of seconds (33) that the server will have to devote to serving this request. Each request is on a single line of the file, with two spaces separating each part of a request from the next part. The entries in the request file are in chronological order.
The following basic policies must be adhered to in scheduling the server.
1. If the server is idle, any request that comes in is started immediately - no delay.
2. If the server is busy, requests that come in can get backed up. The rule for selecting the next request to be serviced when some are waiting is: Choose the waiting request that has the highest priority; and if there is more than one request with equally high priorities, choose the highest priority request that arrived first.
3. There is no preemption. If a request is being serviced, the service is completed for that request regardless of the priorities of waiting requests.
Your program must prompt for and read in the name of the file containing the requests. Then, read the contents of the request file and devise a schedule that fits the policies above. Display the schedule by showing the IP address, starting service time, and ending service time for each request. The display should also show periods of time when the server is idle between time 0 and the completion of the last request. On the back is the sample contents of a short request file, REQUEST1.TXT. Following that is the schedule which should be used for these requests.
20 6 144.80.128.17 12 47 4 144.80.128.18 19 52 8 144.80.128.19 30 60 6 144.80.128.20 15 85 7 144.80.128.21 21 93 9 144.80.128.22 17 158 3 144.80.128.23 22 160 9 144.80.128.24 16 170 2 144.80.128.25 15 172 2 144.80.128.26 33 174 9 144.80.128.27 10 205 4 144.80.128.28 23 240 3 144.80.128.29 16 253 2 144.80.128.30 8 310 5 144.80.128.31 9 315 4 144.80.128.32 12 319 8 144.80.128.33 17
Below is the Request Schedule. Notice that as each request ends at a given time; if there is another request that can start, it begins immediately (having the same start time as the previous request's end time). This same reporting approach is used to show the idle times; i.e., the end of an idle time is the same as the start of the next serviced request and the end of service time for a request is the same as the start of a following idle time.
IP Address Start End
** Idle time ** 0 20
144.80.128.17 20 32
** Idle time ** 32 47
144.80.128.18 47 66
144.80.128.19 66 96
144.80.128.22 96 113
144.80.128.21 113 134
144.80.128.20 134 149
** Idle time ** 149 158
144.80.128.23 158 180
144.80.128.24 180 196
144.80.128.27 196 206
144.80.128.28 206 229
144.80.128.25 229 244
144.80.128.29 244 260
144.80.128.26 260 293
144.80.128.30 293 301
** Idle time ** 301 310
144.80.128.31 310 319
144.80.128.33 319 336
144.80.128.32 336 348