Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

8. (8) Consider the following parallel program: Novice: Apprentice: Expert for )

ID: 3597489 • Letter: 8

Question

8. (8) Consider the following parallel program: Novice: Apprentice: Expert for ) for ) for ) P (assemble) P (start) defect-defect +3 V (done) V (assemble) P (learn) printf ("defective-d ", P (done) P (assemble) defect defect +1 V (learn) P (alarm); defect-defect-2 V(start) V (assemble) defect) V (alarm) Suppose the initialization is: defect=2; alarm=1; start-done-assemble=learn-0. What is the output of the first 3 print statements? (a) (b) Suppose the initialization is defect=5; alarm=0; start-assemble=1 ; done=learn=0. What is the output of the first 3 print statements?

Explanation / Answer

Both the question is related to operating system, based on the sharing of the variables defect,alarm,start,done,assemble,learn.

Whenever we access a particular variable using P , we check if the variable value is greater than 0 or not. If the value is greater than zero, we decrement the value of the variable and start processing the next statement. If the value is 0, then we wait for other process to release the variable using V that increments the variable value by 1.

Using the above concept only, I have determined the answers mentioned below:

(a)  

1st print statement prints 4

2nd print statement prints 6

3rd print statement prints 8

(b)

1st print statement prints 9

2nd print statement prints 11

3rd print statement prints 13

  

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote