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

2

10

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

Frymire answered 19/10, 2014 at 3:50 Comment(0)
N
5

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.

Nudity answered 19/10, 2014 at 4:22 Comment(1)
I am having similar problem, in case of round robin where priority is associated. I am not convinced by my teacher's explanation, that say P1,P2,P3 has the same arrival time and their priority is as : P3>P2>P1. The round robin scheduling order is as P3 -> P2 -> P1 -> P3 -> P2 ->.... I am convinced that this is the logical sequence but my teacher disregards this and claims that the priority will have no effect on round robin scheduling and the order will be as P1->P2->P3->P1...Apostatize
R
0

In priority based round robin scheduling if the arrival time is different of all processes then If the priority of the task is greater than the tasks arriving after it the process will complete its burst. In case a process with higher priority arrives then the task will be preempted and the higher priority task will be executed. We will only use round robin scheduling if there are two tasks with the same priority. Then we shall switch the task with given time slices.

Rancid answered 26/9, 2021 at 2:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.