Round-robin job scheduling may not be desirable if the sizes of the jobs or tasks are highly variable. A process that produces large jobs would be favoured over other processes. This problem may be solved by time-sharing, i.e. by giving each job a time slot or quantum[1] (its allowance of CPU time), and interrupt the job if it is not completed by then. The job is resumed next time a time slot is assigned to that process.
Example: The time slot could be 100 milliseconds. If job1 takes a total time of 250ms to complete, the round-robin scheduler will suspend the job after 100ms and give other jobs their time on the CPU. Once the other jobs have had their equal share (100ms each), job1 will get another allocation of CPU time and the cycle will repeat. This process continues until the job finishes and needs no more time on the CPU.
- Job1 = Total time to complete 250ms (quantum 100ms).
- First allocation = 100ms.
- Second allocation = 100ms.
- Third allocation = 100ms but job1 self-terminates after 50ms.
- Total CPU time of job1 = 250ms.
or one more method to avoid the failure is by dividing the process timing quanta according to their size and time taken such that the ratio becomes equal and all processes ends at same time.
0 comments:
Post a Comment