question archive 'Data structure laboratory' has got 60 systems connected to a server and a printer
Subject:Computer SciencePrice:3.87 Bought7
'Data structure laboratory' has got 60 systems connected to a server and a printer. After the coding gets over, the student wants to take a print out. The printer can serve only one person per time with a buffer to hold 10 programs at a time including the one that is printing at that time. Implement a C Program to automate the process of getting the files printed according to the time of arrival. Use an appropriate data structure. The printer at any time should show the list of files waiting for service.
here is an algorithm:
1.first Create a queue of print tasks. Each task will be given a timestamp upon its arrival. The queue is empty to start.
2.For each second (currentSecond):
2.1 Does a new print task get created? If so, add it to the queue with the currentSecond as the timestamp.
2.2 If the printer is not busy and if a task is waiting,
Remove the next task from the print queue and assign it to the printer.
Subtract the timestamp from the currentSecond to compute the waiting time for that task.
Append the waiting time for that task to a list for later processing.
Based on the number of pages in the print task, figure out how much time will be required.
2.3 The printer now does one second of printing if necessary. It also subtracts one second from the time required for that task.
2.4 If the task has been completed, in other words the time required has reached zero, the printer is no longer busy.
3.After the simulation is complete, compute the average waiting time from the list of waiting times generated.
Purchased 7 times