IF old # new
THEN {
self: PrincOps.PsbHandle = PrincOpsUtils.PsbIndexToHandle[
PDA[PrincOpsUtils.PsbIndexToHandle[PDA.ready.tail]].link.next];
npsb: PrincOps.PsbHandle ← PrincOpsUtils.PsbIndexToHandle[PDA[self].link.next];
IF
PDA[psb].link.vector
THEN {
We need to preserve the number of state vectors at various priorities. The easiest way to do this is to transfer a state vector from the new priority list to the old priority list, which allows the current state vector to remain with the process.
nsv: PrincOps.StateVectorHandle ← PDA.state[new];
IF nsv = PrincOps.NullStateVectorHandle
THEN
GO
TO fail;
If there is no available state vector at that priority, then we lose.
Remove the new state vector from its priority chain
PDA.state[new] ← LOOPHOLE[PDA[nsv].stk[0]];
Give the new state vector to the old priority chain.
PDA[nsv].stk[0] ← LOOPHOLE[PDA.state[old]];
PDA.state[old] ← nsv;
};
At this point we can alter the priority and assume success.
PDA[psb].link.priority ← new;
If the process that is getting its priority changed is on the ready queue we must remove it from the queue and put it back, thereby changing its position in the queue. If it was not on the ready queue, we hope that changing its priority did not upset someone who was depending on priorities being sorted within other kinds of queues. We will see what we will see!
DO
IF npsb = self THEN EXIT;
IF npsb = psb
THEN {
PrincOpsUtils.Requeue[@PDA.ready, @PDA.ready, psb];
EXIT;
};
npsb ← PrincOpsUtils.PsbIndexToHandle[PDA[npsb].link.next];
ENDLOOP;
EXITS fail => {success ← FALSE};
};