Question

In: Computer Science

Explain the main disadvantage of scheduling with preemption. (b) Describe and explain an example. (c) Is...

Explain the main disadvantage of scheduling with preemption. (b) Describe and explain an example. (c) Is the Five Philosophers Problem a synchronization problem? Explain.

Solutions

Expert Solution

a) Explain the main disadvantage of scheduling with preemption.

Preemptive Scheduling is a CPU scheduling technique that works by dividing time slots of CPU to a given process. When the burst time of the process is greater than CPU cycle, it is placed back into the ready queue and will execute in the next chance. This scheduling is used when the process switch to ready state.

Main Disadvantage of Preemptive Scheduling

Takes a higher time by the scheduler to suspend the running task, switch the context, and dispatch the new incoming task. The process which has low priority needs to wait for a longer time if some high priority processes arrive continuously.

In this given figure you can see how the preemptive scheduling done the work of the particular process.

b) Is the Five Philosophers Problem a synchronization problem? Explain.

Yes, the five philosophers problem is a synchronization problem because a solution of the Dining Philosophers Problem (DPP) is to use a semaphore to represent a chopstick. A chopstick can be picked up by executing a wait operation on the semaphore and released by executing a signal semaphore.

The structure of the chopstick is -

semaphore chopstick [5];

Initially the elements of the chopstick are initialized to 1 as the chopsticks are on the table and not picked up by a philosopher.

The structure of a random philosopher i is given -

do {
   wait( chopstick[i] );
   wait( chopstick[ (i+1) % 5] );
   . .
   . EATING THE RICE
   .
   signal( chopstick[i] );
   signal( chopstick[ (i+1) % 5] );
   .
   . THINKING
   .
} while(1);

In the above structure, first wait operation is performed on chopstick[i] and chopstick[ (i+1) % 5]. This means that the philosopher i has picked up the chopsticks on his sides. Then the eating function is performed.

After that, signal operation is performed on chopstick[i] and chopstick[ (i+1) % 5]. This means that the philosopher i has eaten and put down the chopsticks on his sides. Then the philosopher goes back to thinking.

Difficulty in the Solution -

The above solution makes sure that no two neighboring philosophers can eat at the same time. But this solution can lead to a deadlock. This may happen if all the philosophers pick their left chopstick simultaneously. Then none of them can eat and deadlock occurs.

Some of the ways to avoid deadlock are as follows −

There should be at most four philosophers on the table.

An even philosopher should pick the right chopstick and then the left chopstick while an odd philosopher should pick the left chopstick and then the right chopstick.

A philosopher should only be allowed to pick their chopstick if both are available at the same time.


Related Solutions

Explain RR scheduling uses preemption and priorities. (b) Does RR scheduling use multiple classes of processes?...
Explain RR scheduling uses preemption and priorities. (b) Does RR scheduling use multiple classes of processes? Why? Explain.
Explain the main advantage and disadvantage for foreign companies cross-listing shares in the U.S. considering the...
Explain the main advantage and disadvantage for foreign companies cross-listing shares in the U.S. considering the required disclosure.
A. Explain what is climate zone B. Explain an example for a normal climate zone C....
A. Explain what is climate zone B. Explain an example for a normal climate zone C. Describe how it shifts due to global warming?
8. a. What are the three types of firms? b. Explain the advantage and disadvantage of...
8. a. What are the three types of firms? b. Explain the advantage and disadvantage of each type of firm. c. Which type of firm produces the most revenue? 9. a. What are implicit costs? b. Do implicit cost contribute to the opportunity cost of production? Explain c. Should an implicit cost be counted as cost in determining profit? Explain d. Give two examples of implicit costs
A. Describe the process of stripping treasury securities B. Run through an example C. Discuss the...
A. Describe the process of stripping treasury securities B. Run through an example C. Discuss the tax treatment as well as reconstituting a bond
Explain Overview on the Main Industry in Malaysia a) Agriculture b) Manufacturing c) Services d) Construction...
Explain Overview on the Main Industry in Malaysia a) Agriculture b) Manufacturing c) Services d) Construction e) Mining and Quarrying
What is the main advantage/disadvantage associated with the historical cost concept?
What is the main advantage/disadvantage associated with the historical cost concept?
please explain what is meant by critical path scheduling and describe the process of creating Gantt...
please explain what is meant by critical path scheduling and describe the process of creating Gantt charts and Network diagrams
Explain the following with example and formula- a) E0Q b) SAFETY STOCK c) LEAD TIME d)...
Explain the following with example and formula- a) E0Q b) SAFETY STOCK c) LEAD TIME d) RE-ORDER POINT
1. Describe wave scheduling, modified wave scheduling, double booking, overbooking, specified time scheduling,g and walk-ins using...
1. Describe wave scheduling, modified wave scheduling, double booking, overbooking, specified time scheduling,g and walk-ins using complete sentences. 2. Describe the concept of triage when it comes to scheduling and provides an example scenario
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT