Permanent blocking of a set of processes that either compete for system resources or communicate with each other
No efficient solution
Involve conflicting needs for resources by two or more processes
51 trang |
Chia sẻ: tieuaka001 | Lượt xem: 532 | Lượt tải: 0
Bạn đang xem trước 20 trang nội dung tài liệu Operating Systems: Internals and Design Principles, 6/E William Stallings - Chapter 6: Concurrency: Deadlock and Starvation, để xem tài liệu hoàn chỉnh bạn click vào nút DOWNLOAD ở trên
Chapter 6Concurrency: Deadlock and StarvationOperating Systems:Internals and Design Principles, 6/EWilliam StallingsPatricia RoyManatee Community College, Venice, FL©2008, Prentice HallDeadlockPermanent blocking of a set of processes that either compete for system resources or communicate with each otherNo efficient solutionInvolve conflicting needs for resources by two or more processesDeadlockDeadlockDeadlockReusable ResourcesUsed by only one process at a time and not depleted by that useProcesses obtain resources that they later release for reuse by other processesReusable ResourcesProcessors, I/O channels, main and secondary memory, devices, and data structures such as files, databases, and semaphoresDeadlock occurs if each process holds one resource and requests the otherReusable ResourcesReusable ResourcesSpace is available for allocation of 200Kbytes, and the following sequence of events occurDeadlock occurs if both processes progress to their second requestP1. . .. . .Request 80 Kbytes;Request 60 Kbytes;P2. . .. . .Request 70 Kbytes;Request 80 Kbytes;Consumable ResourcesCreated (produced) and destroyed (consumed)Interrupts, signals, messages, and information in I/O buffersDeadlock may occur if a Receive message is blockingMay take a rare combination of events to cause deadlockExample of DeadlockDeadlock occurs if receives blockingP1. . .. . .Receive(P2);Send(P2, M1);P2. . .. . .Receive(P1);Send(P1, M2);Resource Allocation GraphsDirected graph that depicts a state of the system of resources and processesConditions for DeadlockMutual exclusionOnly one process may use a resource at a timeHold-and-waitA process may hold allocated resources while awaiting assignment of othersConditions for DeadlockNo preemptionNo resource can be forcibly removed form a process holding itCircular waitA closed chain of processes exists, such that each process holds at least one resource needed by the next process in the chainResource Allocation GraphsResource Allocation GraphsPossibility of DeadlockMutual ExclusionNo preemptionHold and waitExistence of DeadlockMutual ExclusionNo preemptionHold and waitCircular waitDeadlock PreventionMutual ExclusionMust be supported by the OSHold and WaitRequire a process request all of its required resources at one timeDeadlock PreventionNo PreemptionProcess must release resource and request againOS may preempt a process to require it releases its resourcesCircular WaitDefine a linear ordering of resource typesDeadlock AvoidanceA decision is made dynamically whether the current resource allocation request will, if granted, potentially lead to a deadlockRequires knowledge of future process requestsTwo Approaches to Deadlock AvoidanceDo not start a process if its demands might lead to deadlockDo not grant an incremental resource request to a process if this allocation might lead to deadlockResource Allocation DenialReferred to as the banker’s algorithmState of the system is the current allocation of resources to processSafe state is where there is at least one sequence that does not result in deadlockUnsafe state is a state that is not safeDetermination of a Safe StateDetermination of a Safe StateDetermination of a Safe StateDetermination of a Safe StateDetermination of an Unsafe StateDeadlock Avoidance LogicDeadlock Avoidance LogicDeadlock AvoidanceMaximum resource requirement must be stated in advanceProcesses under consideration must be independent; no synchronization requirementsThere must be a fixed number of resources to allocateNo process may exit while holding resourcesDeadlock DetectionStrategies Once Deadlock DetectedAbort all deadlocked processesBack up each deadlocked process to some previously defined checkpoint, and restart all processOriginal deadlock may occurStrategies Once Deadlock DetectedSuccessively abort deadlocked processes until deadlock no longer existsSuccessively preempt resources until deadlock no longer existsAdvantages and DisadvantagesDining Philosophers ProblemDining Philosophers ProblemDining Philosophers ProblemDining Philosophers ProblemDining Philosophers ProblemUNIX Concurrency MechanismsPipesMessagesShared memorySemaphoresSignalsUNIX SignalsLinux Kernel Concurrency MechanismIncludes all the mechanisms found in UNIXAtomic operations execute without interruption and without interferenceLinux Atomic OperationsLinux Atomic OperationsLinux SpinlocksLinux SemaphoresLinux Memory Barrier OperationsSolaris Thread Synchronization PrimitivesMutual exclusion (mutex) locksSemaphoresMultiple readers, single writer (readers/writer) locksCondition variablesSolaris Synchronization Data StructuresWindows Synchronization Objects
Các file đính kèm theo tài liệu này:
- chapter06_rev_3694.pptx