� An algorithm to recover from the deadlock
DEADLOCK
� An algorithm to recover from the deadlock
DEADLOCK
The case of never enter.
Restrain the ways request can be made (at least one of the necessary conditions should not be true).
� Mutual Exclusion – not required for sharable resources; must hold for nonsharable resources.In general not possible to prevent deadlock by this, some resources are intrinsically non-sharable
� Hold and Wait – must guarantee that whenever a process requests a resource, it does not hold any other resources.
* Require process to request and be allocated all its resources before it begins execution, or allow process to request resources only when the process has none.
* Low resource utilization; starvation possible.
� No Preemption –
* If a process that is holding some resources requests another resource that cannot be immediately allocated to 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.
� Circular Wait – impose a total ordering of all resource types, and require that each process requests resources in an increasing order of enumeration.
DEADLOCK
� We can allow the system to enter a deadlock� state and then recover
� We can ignore the problem all together, and pretend that deadlocks never occur in the system.
� Deadlock prevention is a set of methods for ensuring that at least one of the necessary conditions cannot hold.
� Deadlock avoidance, on the other hand, requires that the operating system be given in advance additional information concerning which resources a process will request and use during its lifetime.
DEADLOCK
Mutual exclusion - only one process at a time can use a (non-sharable) resource.
Hold and wait - a process holding at least one resource is waiting to acquire additional resources held by other processes.
No preemption - a resource can be released only voluntarily by the process holding it, after that process has completed its task.
Circular wait - there exists a set {P0, P1, …, P0} of waiting processes such that P0 is waiting for a resource that is held by P1, P1 is waiting for a resource that is held by P2, …, Pn–1 is waiting for a resource that is held by Pn, and P0 is waiting for a resource that is held by P0.
• An application can be a set of threads that cooperate and execute concurrently in the same address space
• Threads running on separate processors yields a dramatic gain in performance
• Local Scheduling – How the threads library decides which thread to put onto an available LWP
• Global Scheduling – How the kernel decides which kernel thread to run next
• Whenever a CPU needs a process to run, it takes the next task from the ready list.
• The scheduling queue must be accessed in a critical section. Busy waiting is usually used.
• Load sharing
• Gang scheduling
– A set of related threads is scheduled to run on a set of processors at the same time
• Dedicated processor assignment
– Threads are assigned to a specific processor
• Dynamic scheduling
– Number of threads can be altered during course of execution
Will consider only shared memory multiprocessor
Salient features:
One or more caches: cache affinity is important
Semaphores/locks typically implemented as spin-locks: preemption during critical sections
Central queue – queue can be a bottleneck
Distributed queue – load balancing between queue
REAL - TIME SCHEDULING
• Many real time systems run a known collection of tasks. The execution time of the tasks is frequently known ahead of time.
• If a task that runs for 3 time units must be done at time 10, it must start by time 7.
• If two tasks that runs for 3 time units each must be done at time 10, one must start by time 4.
• Soft real-time computing – requires that critical processesreceive priority over less fortunate ones.
Correctness of the system may depend not only on the logical result of the computation but alsoon the time when these results are produced,
– Tasks attempt to control events or to react to eventsthat take place in the outside world
– These external events occur in real time andprocessing must be able to keep up
– Processing must happen in a timely fashion
• neither too late, nor too early
• EDF – Earliest Deadline First Scheduling
• Static table-driven
– Table determines at run time when a task begins execution
• Static priority-driven preemptive
– Traditional priority-driven scheduler is used
• Dynamic planning-based
– Feasibility determined at run time
• Dynamic best effort
– No feasibility analysis is performed
