in Operating System
936 views
0 votes
0 votes
How the lock variable software synchronization mechanism guarantee that deadlock can never happen in lock variable??
in Operating System
936 views

2 Answers

1 vote
1 vote
Lock variable synchronization mechanism failed because reading and modifying the the lock variable isn't an atomic operation; so more than one process can read the value of lock variable as 0(i.e. 0 denotes critical section is unoccupied) and enter into the critical section by making the lock value as 1. Hence lock variable doesn't guarantee mutual exclusion. As mutual exclusion is one of the necessary conditions for deadlock to happen, so lock mechanism guarantees that deadlock can't happen as mutual exclusion isn't provided.

6 Comments

 As mutual exclusion is one of the necessary conditions for deadlock to happen

it is true, but there is some restriction, just check the comments of https://gateoverflow.in/226875/critical-section

0
0
@Shaik saw that link.. But then why do we say that in order to prevent deadlock, we must disable one of the necessary conditions like for ex.  If  we disable mutual exclusion condition, then deadlock will be prevented. Is this false then ?
0
0

 If  we disable mutual exclusion condition, then deadlock will be prevented.

it is true but on some restriction. 

0
0
The restriction is that entry section of the processes have to be same.. So in lock mechanism, entry section of the processes are all same. So in this case can we say that no mutual exclusion implies no deadlock?
0
0
yes....
0
0
Ok got it..thanks :)
0
0
0 votes
0 votes
1. lock variable is a sowfware mechanism implement in user mode.

2. Busy waiting solution (in this busy waiting occur)

3.can be used even for more then two process

But lock variable does'n gurantee mutual exclusion means two or more process can simultaneously enter into critical section.As mutual exclusion is one of the necessary conditions for deadlock to happen, so lock mechanism guarantees that deadlock can't happen as mutual exclusion isn't provided.

Related questions