This is addressed in many scheduling algorithms by a technique called
"priority inversion" or "priority inheritance". The OS can tell when a high
priority process is waiting for a lower priority one to finish. When this
happens, it temporarily boosts the priority of the process holding the lock
to the same (or even higher) priority than the process that is waiting. This
prevents starvation and allows the waiting higher priority process to
continue as soon as possible. Of course after the waiting process is
released, the lower priority process gets kicked back down to where it was in
the first place.