Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

operating systems questions please solve this problem clearly Tom and Jim are roommates. They love milk but when each go to store to buy a

image text in transcribed

image text in transcribed

image text in transcribed

operating systems questions please solve this problem clearly

Tom and Jim are roommates. They love milk but when each go to store to buy a milk, they have the problem of too much milk (two bottles) since they both can buy milk independently. They are looking for Tom I sriow that it is possible that the above solution may result in two bottles of milk at home, we will use the following terminology. TSO means Tom executes Statement 0, TS1 means Tom executes Statement 1 , etc. Similarly, JSO means Jim executes Statement 0, JS1 means Jim executes Statement 1, etc. The following sequence illustrates the problem when the instructions are executed from left to right, in sequence. TSO, TS1, JSO, JS1, JS2, TS2, TS3, JS3, JS4, TS4 The correctness properties for the too much milk problem are: i) never more than one person buys an ii) someone buys if needed Use the above notation showing the execution order of instructions to answer questions 1 and 2. 1. Show that the following solution does not work by writing the order of execution of instruc and write why it does not work (20 points) Tom TSO: Note_from_Tom_to_Jim =1; TS1: If Note_from_Jim_to_Tom ==0}/ if Jim did not leave a note to Tom TS2: If milk ==0{// if no milk at home TS3: milk=milk 1;1// milk is bought TS4: //come home put the milk in the refrigerator TS5: TS6: TS7: Note_from_Tom_to_Jim =0; Jim JS0: Note_from_Jim_to_Tom =1; JS1: If Note_from_Tom_to_ Jim==0(// if Tom did not leave a note to Jim JS2: If milk =001// if no milk at home JS3: milk=milk+1; // milk is bought JS4: // come home put the milk in the refrigerator JSS: J \( \begin{array}{ll}\text { JS6: } \quad \text { JS7: } & \text { Note_from_Tom_to_Jim }=\$\end{array} \) 5. Use semaphores for the four threads to print the statement ( 20 points) Rule of operating systems class: If it seems easy, you are probably doing it wrong. Thread 0 Thread 1 Thread 2 Thread 3 of Rule operating systems If class: it seems easy, you are probably doing it wrong. 2. Show that the following solution does not work by writing the order of execution and write why it does not work (20 points) TSO: If milkus ( I/ll no millk at home ande at home to say gone to buy milik //come home pul the milk in the refrigerator note 0 i l //come home put the milk in the refrigerator nole =0; ) simultaneously used correctly. (20 points)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Application Development And Administration

Authors: Michael V. Mannino

3rd Edition

0071107010, 978-0071107013

More Books

Students also viewed these Databases questions