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

Do you know what is a binary semaphore?

610


How can you check whether a machine is 64 bit or 32 bit?

638


Is 64gb ram enough for gaming?

572


What are old chkdsk files?

610


What layer is http?

572






How can I make usb bootable?

536


Explain the stipulations of c2 level security?

640


What is the maximum ram for a 64 bit operating system?

535


What is the unified memory architecture? Explain.

586


What first program that the computer runs when the power is turn on?

582


Explain how a TP Monitor manages memory and processor resources more effectively than a typical operating system.

1461


Hello this is gaurav garg I have completed BCA. plz TEll me how will ask question in interview.

1739


What is the purpose of system calls?

616


Describe system calls and its type

598


What items of information about a task might be useful in real time scheduling?

2002