|
Sometimes a process needs something that is not available....a free disk buffer, some data from disk, or maybe just a signal. So it will go to sleep and wait for the resource to become available. This act of sleeping on a resource is what raises a process' priority to a kernel priority. But a sleeping process is not using a cpu. When the resource becomes available, the process will run at the elevated level, but, if the kernel is well written, this will be a very short time. Either it will sleep for something else or it will return to user mode. At return to user mode time, the priority is recalculated. Since the process recently spent time asleep, it will get credit for not hogging the cpu.
Thus very high priority processes tend to not be running and do not want the cpu. The quantum is based on cpu time, not elapsed time. But if the quantum were to be consumed while the process is in system mode, this will be detected upon the return to user mode.
But no matter how high the priority is, if another higher priority wants the cpu, the lower priority process will be preempted. You are getting confused with another issue. Unix guarantees that some system calls are atomic. To meet this guarantee, it has a concept of very high priority. The difference is a that a very high priority process will not wake up if a signal is sent to it. The signal will be pending until its priority lowers somewhat. If a process is writing to a disk file, it will not be signalable until the write completes. But if a process is writing to a tty, a signal can interrupt the write before it completes.
|