死锁与进程的推进顺序有关。若修改P的代码,则不会产生死锁Process PGet ARelease AGet BRelease B
死锁与进程的推进顺序有关。若修改P的代 码,则不会产生死锁 Process P . Get A . Release A . Get B . Release B
ProgressofQ3ReleaseA4-AReleaseandRequlredB-wantA1--IandGetAwantB---Requlred5GetB--I6ProgressofpGetAReleaseAGetBReleaseBARequtredBRequlredFigure6.3ExampleofNoDeadlock[BACO98
ReusableResources(可重用资源),资源通常可分为两类:可重用的和可消费的 Used by one process at a time and not depletedbythatuse(可重用资源是指一次只能供一个进程安全地使用,并且不会由于使用而耗尽。),可重用资源释放之后供其他进程再次使用。,可重用资源的例子:Processors、IOchannels.main and secondary memory(辅存)、files、databases、 and semaphoresDeadlock occurs if each process holds oneresource and reguests the other
Reusable Resources (可重用资源) • 资源通常可分为两类:可重用的和可消费的。 • Used by one process at a time and not depleted by that use ( 可重用资源是指一次只能供一个 进程安全地使用,并且不会由于使用而耗尽。) • 可重用资源释放之后供其他进程再次使用。 • 可重用资源的例子:Processors、 I/O channels, main and secondary memory(辅存)、files、 databases、 and semaphores • Deadlock occurs if each process holds one resource and requests the other
ExampleofDeadlockProcess QProcess PStepStepActionActionPoqoRequest (D)Request (T)Lock (T)Lock (D)Piq1Request (T)Request (D)P22Lock (T)Lock (D)P393PerformfunctionPerformfunctionP4q4Unlock (D)Unlock (T)PsqsUnlock (T)PUnlock (D)46Figure 6.4 Example of Two Processes Competing for ReusableResources
Example of Deadlock
AnotherExampleofDeadlock: Space is available for allocation of 200Kbytes, and the following sequence ofevents occurP1P2Request 70K bytes;Request 80K bytes;Request 80K bytes;Request 60Kbytes;. Deadlock occurs if both processesprogress to their second request
Another Example of Deadlock • Space is available for allocation of 200K bytes, and the following sequence of events occur • Deadlock occurs if both processes progress to their second request P1 . . . . . . Request 80K bytes; Request 60K bytes; P2 . . . . . . Request 70K bytes; Request 80K bytes;