Selfish Round Robin CPU Scheduling


Scheduling algorithms in the operating system execute the processes based on their arrival time or by their priority. Each algorithm chooses the processes that are in waiting to ready queue by preemption or non-preemption methods. Preemptive algorithms provide access to the CPU to the process which has higher priority and preempt any other process which is already running with lower priority. But in the case of non-preemptive scheduling, when processes start their execution, it cannot be preemptive even when higher priority processes are in the ready state.

The traditional round-robin scheduling algorithm is a preemptive one where each process gets a fixed amount of time slice or quantum for its execution. Process after the given time slice goes to the end of the queue and other processes which are in the ready queue are served in the FCFS pattern. The selfish round-robin algorithm is a variant of the traditional one but it offers support to the processes that are executing longer with high priority and provides better implementation than the traditional method.

Selfish round-robin scheduling

This algorithm provides CPU resources to the processes that are executing for a longer time with higher priority and other processes in the queue can increase its priority to get the CPU in a short time, so-called the name ‘selfish’. Each process that is in the ready queue is assigned a priority level and the processes with higher priority receive maximum CPU time than the processes with lower priority

Here, two lists are created for all the processes that are in the ready queue as New and Accepted. The process which enters the queue for the first time should wait until the Accepted process completes its service. All the processes in the list get equal CPU time by applying the traditional round-robin approach, where each process is assigned with time slice to execute, and after completing the execution within the time slice, it is appended to the end of the queue thereby providing a chance to the next process to execute.

Consider an example of P1, P2, and P3 are the three different processes where each has different levels of priority. P1 is assigned as a high priority, followed by P2, and the least priority is for P3. A round-robin distribution with a predefined time slice is set for each process.

  • Process P1 can request the operating system to raise its priority at any moment. The remaining process’s priority level would change by OS.

  • The remaining process’s priority level would change by OS. Process P2 would request a priority containing a higher level, the OS would adjust the priority levels given to P2 with a higher priority level as compared to P1 and P3

  • So, now Process P2 will have maximum CPU time for the next process.

  • If a process makes unnecessary use of the given time slice, this may lead other processes to wait for a longer time.

  • This encourages processes to utilize the CPU effectively as opposed to dominating it. From this example, the basic idea of SRR is illustrated, where each process can alter its priority dynamically depending on its activity, such as how much CPU time it has used or how long it has been waiting for the CPU.

  • SRR can be applied in several ways, with various standards for raising or lowering a process priority. The system may consider the size of a process or the amount of CPU time it has used waiting for the CPU.

Advantages

  • System throughput is increased by making use of the CPU efficiently as each process has to utilize only the CPU time required for execution.

  • Each process would assign an equal amount of CPU time according to the Round Robin algorithm.

Drawbacks

  • Any process can act selfishly to utilize all of the allocated CPU time, even when not needed. So other processes keep waiting for a longer time to acquire the CPU to perform its processing.

  • perform its processing. It may not be a suitable algorithm for real-time systems that work on the principle of time constraints, where each process or task has to be completed within the given period.

  • Response time is higher, for the processes that require less CPU time as it has to wait for Accepted processes to complete their quantum time

Conclusion

Selfish round-robin scheduling provides efficient CPU time for the processes with high priority and new processes have to wait till the high-priority process completes its service time. It is more efficient than normal round-robin scheduling or other priority-based scheduling techniques. CPU never gets idle time as processes keep executing for a long time and other processes that are in the ready queue have their priority to complete their execution within the given time slice. But the main drawback is that it cannot support real-time systems where discrete events have to be processed.

Updated on: 18-Jul-2023

336 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements