Question: . . Assignment - 3 : Queue Each task arrives to CPU at every second and requests to be processed by CPU with a pair

..
Assignment -3: Queue
Each task arrives to CPU at every second and requests to be processed by CPU with a pair of values (taskID, processingTime).(Note that taskID is a sequential number starting from 1.) This request is inserted into a queue. Then, CPU deletes a request from the queue and processes it for 1 second. If the task is not yet completed, then it is re-inserted into the queue with (taskID, processingTime-1) after inserting all other arriving tasks. For example, a list of tasks is given as below:
The processing at every second is
[0th second](13) arrives
- Add (13) to queue,
- Delete a task from queue ->(13), and
- Process it for 1 second: (13) becomes (12)
[1st second](21) arrives
- Add (21) to queue,
- Add (12) to queue,
- Delete a task from queue ->(21), and
- Process it for 1 second: (21) is completed
[2nd second](34) arrives
- Add (34) to queue
- Delete a task from queue ->(12)
- Process it for 1 second: (12) becomes (11)
[3rd second] no further task arrives:
- Add (11)
- Delete a task from queue ->(34)
- Process it for 1 second: (34) becomes (33)
[4th second] no further task arrives:
- Add (33)
- Delete a task from queue ->(11)
- Process it for 1 second: (11) is completed
[5th second] no further task arrives:
- Delete a task from queue ->(33)
- Process it for 1 second: (33) becomes (32)
[6th second] no further task arrives:
. . Assignment - 3 : Queue Each task arrives to

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!