Question: 1_ The program example shown down doesnt always lead to deadlock. Describe what role the CPU scheduler plays and how it can contribute to deadlock

1_ The program example shown down doesnt always lead to deadlock. Describe what role the CPU scheduler plays and how it can contribute to deadlock in this program.

/* thread one runs in this function */ void *do work one(void *param) { pthread mutex lock(&first mutex); pthread mutex lock(&second mutex); /** * Do some work */ pthread mutex unlock(&second mutex); pthread mutex unlock(&first mutex); pthread exit(0); } /* thread two runs in this function */ void *do work two(void *param) { pthread mutex lock(&second mutex); pthread mutex lock(&first mutex); /** * Do some work */ pthread mutex unlock(&first mutex); pthread mutex unlock(&second mutex); pthread exit(0); }

2_Consider a system consisting of four resources of the same type that are shared by three processes, each of which needs at most two resources. Show that the system is deadlock free. 3_ Consider the version of the dining-philosophers problem in which the chopsticks are placed at the center of the table and any two of them can be used by a philosopher. Assume that requests for chopsticks are made one at a time. Describe a simple rule for determining whether a particular request can be satisfied without causing deadlock given the current allocation of chopsticks to philosophers.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!