What is Concurrency? Expain with example Deadlock and
Starvation?

Answer Posted / manoj

Deadlocks and Starvation
Readings: Chapter on Deadlocks in Tanenbaum. You can skip
Deadlock
Detection and Banker’s Algorithm.
· We looked at solving synchronization problems using
monitors and
semaphores.
· Unfortunately, problems can arise
Example 1:
Recall our solution to the reader-writer problem. It was
possible for
readers to wait indefinitely if new writers kept coming in.
On the other hand, writers would not wait indefinitely as
long as ready
threads are served in order.
Why?Thread A Thread B
lock(x)
lock(y)
Use resource X and Y
Unlock(y)
Unlock(x)
Lock(y)
Lock(x)
Use resource X and Y
Unlock(x)
Unlock(y)
In this case, it is possible that both Thread A and Thread B
wait
indefinitely for each other, with no progress being made.
What is common and different between the above examples?
Common aspect: Both problems involve threads waiting for
resources to
become available. They can also involve
· Resources: things needed by a thread to do its job a
thread *waits*
for resources
o e.g., locks, AW+WW = 0 (i.e., database is free from active or
waiting writers), disk blocks, memory pages
· Indefinite wait: In both examples, a thread may end up waiting
indefinitely.
Differences between the two examples: The type of waiting is
different.
· Starvation
A thread may wait indefinitely because other threads keep coming
in and getting the requested resources before this thread
does. Note that
resource is being actively used and the thread will stop
waiting if other
threads stop coming in.
· Deadlocks
A group of threads are waiting for resources held by others
in the
group. None of them will ever make progress.
Example 1 has starvation, but Example 2 does not.
A solution to a synchronization problem suffers from the
starvation
problem if starvation is a possibility. Usually, differences
in priorities can
lead to starvation. Lower priority threads starve if higher
priority threads
keep requesting the resources.
A solution suffers from the deadlock problem if a deadlock
is a possibility.
In Example 2, will a deadlock always occur?

Is This Answer Correct ?    1 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is operating system and examples?

538


List the sub-components of i/o manager in windows nt?

529


Explain migration process?

544


How often should I run chkdsk?

526


What grep means?

510






Explain briefly about compiler and its functioning?

608


What are interrupts?

696


What complications does concurrent processing add to an operating system?

667


Have you used threaded trees anytime in your life time?

716


What is the purpose of an I/O status information?

634


What is interprocess communication in os?

651


What are the two types of file system?

564


Explain about local and global page replacements?

522


How can I run 32 bit on 64 bit?

536


What is tcl timing?

578