Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

priority based round robin algorithm in operating system: is this preempted?

Tags:

round-robin

in priority based round robin algorithm, when higher priority process (let's say P1) is arrived during lower priority process (P2) is processing, P2 must be preempted and P1 is processed instead. right?

then what if, after specific time quantum (ex. 10ms)

  • is P1 keep processed? (since P1 has a higher priority)

  • or P1 is preempted and scheduler dispatch P2 (because in round robin, after the time quantum, job must be switched)

i think the second thought is right, but book is confusing me. (operating system concepts international ver. exercise 5.8)

thanks a lot

like image 726
HyunsooKim Avatar asked Oct 19 '14 03:10

HyunsooKim


People also ask

Is priority based algorithm preemptive?

Priority Based Scheduling Priority scheduling is a non-preemptive algorithm and one of the most common scheduling algorithms in batch systems. Each process is assigned a priority. Process with highest priority is to be executed first and so on.

Does Round Robin have preemption?

Round-robin algorithm is a pre-emptive algorithm as the scheduler forces the process out of the CPU once the time quota expires.

Is Round Robin preemptive or Nonpreemptive?

Examples of preemptive scheduling are Round Robin and Shortest Remaining Time First. Examples of non-preemptive scheduling are First Come First Serve and Shortest Job First.

Can a round robin scheduling algorithm be non preemptive?

You are right, Round Robin is the preemptive approach to FCFS, and FCFS is the non-preemptive approach to Round Robin. Other than that the algorithms have almost everything in common. Though I would still say that Round Robin is distinctly different from FCFS due to its preemptiveness.


1 Answers

This depends. How this is implemented in normal Round Robin, where there is no priority then we should preempt to P2. But this has priority to it, which we do preempt, but to whatever process happens to have the next highest priority (to keep things simple).

Let's assume that it is implemented in this way:

  • Processes are only preempted via the time slice of the Round Robin
  • Priority will simply be based on the order the processes are executed in RR (to avoid starvation problems)

This may be different than what your book has, for example it may increase the priority of processes based on how long they have been in the queue, then preempt to the current highest (in which may be the same process). But the way I defined above it more focus on the Round Robin fair sharing. In this case P1 is preempted and we move to P2, the same way normal RR works.

But lets move into a better example say we have P1 (priority = high), P2 (priority = low), and P3 (priority = med). And then enter the queue in the order of: P1, P2, P3. Then from how I defined Priority RR will do this:

P1 -> [high] Notice the priority simply changes the ordering
P3 -> [med]  But each still has the same time slice.
P2 -> [low]
P1
P3
P2

Each with a N time slice. Surely yes it does not seem Priority is playing a big factor here, RR is more focus on. But as the number of process in the ready queue are large (and perhaps the time slice is large), then it will play a bit of a bigger factor.

like image 126
Spencer Wieczorek Avatar answered Oct 21 '22 06:10

Spencer Wieczorek