Operating System Priority Loop Algorithm: Is it Unloaded?

in a priority-priority cyclic algorithm algorithm, when a process of a higher priority (let it be said, P1) comes in a process of lower priority (P2), it is processed, P2 must be unloaded and P1 is processed instead. is not it?

what if after a certain quantum of time (for example, 10 ms)

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

  • or P1 is unloaded and the dispatch manager P2 (because in the circular mode, after the time slice, the task must be switched)

I think the second thought is correct, but the book is confusing to me. (operating system concept, international version of exercise 5.8)

Thank you very much

+6
source share
1 answer

It depends. As it is implemented in the usual Round Robin, where there is no priority, then we must preempt P2. But this has a priority for him, which we exaggerate, but no matter what process has the next highest priority (so that everything is simple).

Suppose it is implemented in this way:

  • Processes are only unloaded using the Round Robin temporary fragment.
  • The priority will simply be based on the order of the processes in the RR (to avoid problems with starvation)

This may differ from what is in your book, for example, it can increase the priority of processes depending on how long they were in the queue, and then pre-empt the current maximum (in which there can be one and the same process). But, as I defined above, is more focused on Round Robin sharing. In this case, P1 unloaded and we go to P2 , just as normal RR works.

But let's move on to a better example, say that we have P1 (priority = high) , P2 (priority = low) and P3 (priority = med) . And then enter the queue in the order: P1, P2, P3. Then, as I defined Priority RR, you will do the following:

 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 temporary fragment of N Of course yes, it does not look. Priority plays a big role here, RR pays more attention. But since the number of processes in the finished queue is large (and, possibly, the time slice is large), then it will play a slightly larger factor.

+4
source

Source: https://habr.com/ru/post/976923/


All Articles