Question: The program example below: Deadlock example. doesn t always lead to dead - lock. Describe what role the CPU scheduler plays and how it can
The program example below: Deadlock example. doesnt always lead to deadlock. Describe what role the CPU scheduler plays and how it can contribute to deadlock in this program.
threadone runs in this function
void doworkonevoid param
pthreadmutexlock&firstmutex;
pthreadmutexlock&secondmutex;
Do some work
pthreadmutexunlock&secondmutex;
pthreadmutexunlock&firstmutex;
pthreadexit;
threadtwo runs in this function
void doworktwovoid param
pthreadmutexlock&secondmutex;
pthreadmutexlock&firstmutex;
Do some work
pthreadmutexunlock&firstmutex;
pthreadmutexunlock&secondmutex;
pthreadexit;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
