16.05.2015 Views

Working with the Unix OS

Working with the Unix OS

Working with the Unix OS

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Process Scheduling<br />

Figure 47. Range of Process Priorities<br />

The kernel does not allow processes<br />

<strong>with</strong> user level priority to cross <strong>the</strong><br />

threshold and attain kernel level<br />

priority, unless <strong>the</strong>y make a system<br />

call & goto sleep.<br />

! priority dependent on reason for<br />

sleeping<br />

- A process sleeping and waiting<br />

for completion of disk I/O has a<br />

higher priority than a process<br />

waiting for a free buffer.<br />

- Process waiting for I/O already<br />

has a buffer, when it wakes up it<br />

may release <strong>the</strong> buffer. The more<br />

resources free, <strong>the</strong> better chance<br />

processes will not block waiting<br />

for resources.<br />

- Fewer context switches, thus<br />

process response time and system<br />

throughput are better.<br />

- Process waiting for a free buffer<br />

may be waiting for buffer held by<br />

process waiting on I/O.<br />

The kernel adjusts <strong>the</strong> priority of a process that returns from kernel mode to user mode. The kernel recomputes <strong>the</strong><br />

priority of all active processes once<br />

a second. At every clock interrupt,<br />

<strong>the</strong> clock handler increments <strong>the</strong><br />

recent CPU usage.<br />

decay (CPU) = CPU_usage /2<br />

priority = decay (CPU) +<br />

base level priority<br />

Figure 48. Process Scheduling<br />

Example<br />

171

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!