13.07.2015 Views

An Operating Systems Vade Mecum

An Operating Systems Vade Mecum

An Operating Systems Vade Mecum

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.

122 Resource Deadlock Chapter 4file may represent a load image that the preempted process was in the middle of linking.Some links are complete and others are not. In this case, preemption injures the resource,and it might never again be usable. The incompletely linked image cannot be loaded, norcan the linking be finished.Even though they are not preemptable, the resources we will discuss are all seriallyreusable. After one process has finished using a tape drive, some other process maycertainly use it without harm.<strong>An</strong>other property of the resources we will discuss here is that they are bothdiscrete and bounded. This means that they come in individual chunks and that theamount of the resource is limited, usually physically. For example, if an installation hasonly seven tape drives, it makes no sense to acquire 3.4 of them or 8 of them. Time, incontrast, is neither discrete nor bounded. The scheduler can divide it into pieces of anysize, and there is always enough to satisfy any finite process.We will speak of resource classes, which are sets of identical resources. If a processdoes not care which tape drive it gets, then all tape drives are identical as far as it isconcerned, and they are therefore in the same class. Likewise, in an installation withseveral line printers, it is often immaterial which line printer is acquired; all line printersare in the same class.1 NUTS AND BOLTSWe will assume that when a process needs a resource, it will ask the kernel for it by makinga service call. The part of the kernel responsible for these requests is the resourcemanager. The same service call might ask for several resources at a time. If theresources desired are available and the resource manager decides to grant them, the processis allowed to continue. The fact that the process now possesses the resources ismarked in its context block, and the resources are marked as belonging to that process.The resource manager might decide not to grant the resources. In this case, theprocess is placed in a resource-wait list, where it remains until the resource managerdecides to honor it with the resources. (Instead, the resource manager could reportfailure immediately or after a delay.)When the process has finished using one or more resources, it returns them by issuinganother service call. This call does not block the process, although the scheduler maytake this opportunity to switch to a different process for a while. If a process tries to usea resource it has not acquired, the resource manager treats this action as an error.Here is a sample of the declarations needed for these service calls:

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

Saved successfully!

Ooh no, something went wrong!