(0)Deadlock Prevention

Restrain the ways requests can be made to break one of the four necessary conditions for deadlocks

  • We try to ensure that one of the four necessary conditions cannot hold, then we can prevent it
  • Mutual Exclusion:
    -If it is shareable resource, then we can break the mutual exclusion (such as: Read-only file)
    -If it is not a shareable resource, then mutual exclusion must hold (such as: Printer)
  • Some devices (such as printer) can be spooled

– only the printer daemon uses printer resource

– thus deadlock for printer eliminated

  • Not all devices can be spooled

  • Hold and wait: two methods
    1. Require process to request and be allocated all its resources before it begins execution.
    2. allow process to request resources only when the process has none.

  • NO preemption:

  • If a process that is holding some resources requests
    another resource that cannot be immediately to
    allocated it, then all resources currently being held are
    released.
  • Preempted resources are added to the list of resources
    for which the process is waiting.
    Process will be restarted only when it can regain its old
    resources, as well as the new ones that it is requesting.
  • Attacking the No Preemption Condition:
  • Preemption– when a process is holding some resources and waiting for others, its resources may be preempted to be used by others
  • Problem– Many resources may not allow preemption; i.e., preemption will cause process to fail

  • Attacking the Circular Wait Condition:

  • impose a total order of all resource types; and require that all processes request resources in the same order

0 comments:

Post a Comment