Rss Feed

DEADLOCK

DEADLOCK DETECTION
� An algorithm that examines the state of the system to determine whether a deadlock has occurred

� An algorithm to recover from the deadlock
Allow system to enter deadlock state
Detection algorithmn
Recovery scheme

DEADLOCK

DEADLOCK PREVENTION

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

METHOD FOR HANDLING DEADLOCKS
Never enter (prevention & avoidance), detect/recover, ignore…
We can use a protocol to ensure that the system will never enter a deadlock state.
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.
This solution is the one used by most operating systems, including UNIX.
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.
Ensure that the system will never enter a deadlock state.
Allow the system to enter a deadlock state and then recover.
Ignore the problem and pretend that deadlocks never occur in the system; used by most operating systems, including UNIX.

DEADLOCK

DEADLOCK CHARACTERIZATION
Deadlock can arise if four conditions hold simultaneously.

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.

Thread Scheduling
• Executes separate from the rest of the process
• 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
Multiprocessor Scheduling
• Very little has to be done to schedule a multiprocessor system.
• 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
– Processes are not assigned to a particular processor
• 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.


• Tasks have deadlines by which they must complete.


• 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.


Hard real-time systems – required to complete a critical taskwithin a guaranteed amount of time.


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,

example:

– 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