The solution is to apply a numerical ordering to all the resources, and to require processes to lock
resources in numerical order. For instance, suppose these resources are given this numerical ordering (the order
is arbitrary):
1 File X
2 File Y
3 Printer
4 Tape drive
5 CD-ROM drive
6 Plotter
If a process needs to have exclusive access to file X and file Y, it must lock the files in that order. Likewise,
if a process first locks the printer, it may not then lock either file. Having locked the printer, however, the
process could still go on to lock the CD-ROM drive.
It can be shown rather easily that such a scheme will prevent circular wait. The difficulty in a general-purpose
operating system is to enforce such a discipline among all the application programs. In addition, if the more
abstract resources such as entries in various system tables, and individual records in files, are considered
resources, the complexity of the ordering becomes much greater.
Because of these implementation problems, general-purpose operating systems do not provide such a facility
for deadlock prevention. However, this principle can be of great practical value to application developers who
work with complex, multithreaded applications.
Pages:
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304