Final Unit 5 Spos 2023
Final Unit 5 Spos 2023
Concurrency Control”
Prepared By
Prof. Anand N. Gharu
(Assistant Professor)
PVGCOE Computer Dept.
Race conditions –
1. Mutual exclusion
2. Progress
3. Bounded waiting
• Mutual Exclusion
• Progress
• Bounded Waiting
• Architectural Neutrality
1. Shared memory
2. Message passing
message passing :.
in this, instead of reading or writing, processes send and receive the
messages.
send and receive functions are implemented in OS.
The two most common kinds of semaphores are counting semaphores and
binary semaphores. Counting semaphore can take non-negative integer
valuesProf.
and Binary
Gharu semaphore can take the value 0 & 1. only.
Anand N. 30
Types of Semaphore
Semaphores are a useful tool in the prevention of race conditions; however,
their use is by no means a guarantee that a program is free from these
problems. Semaphores which allow an arbitrary resource count are
called counting semaphores, while semaphores which are restricted to the
values 0 and 1 (or locked/unlocked, unavailable/available) are
called binary semaphores and are used to implement locks.
1. wait()
2. Signal()
Access When any process access the When any process wants to
shared resources it perform wait() access the shared variables in
operation on S and when it the monitor, it needs to
releases the shared resources it access it through the
performs signal() operation on S. procedures.
Eliminate No Preemption
Preempt resources from process when resources required by other high priority process.
Consider there are n account holders in a bank and the sum of the money in
all of their accounts is S. Everytime a loan has to be granted by the bank, it
subtracts the loan amount from the total money the bank has. Then it
checks if that difference is greater than S. It is done because, only then, the
bank would have enough money even if all the n account holders draw all
their money at once.
Banker's algorithm works in a similar way in computers. Whenever a new
process is created, it must exactly specify the maximum instances of each
resource typeAnand
Prof. Gharu that N.it needs. 48
Deadlock Avoidance
Let us assume that there are n processes and m resource types. Some data structures
are used to implement the banker's algorithm. They are:
Email : [email protected]