Question

Exercise 4.4.1: Tracing a monitor execution. About While a process is executing inside the function A of the monitor m, the f

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Let us first understand wait and signal operation.

wait(): process which performs wait operation on condition variable c will get suspended and will be placed in block queue of c.
signal(): Wherever a process performs a signal operation on condition variable c, one process from blocked queue of c will be executed. If block queue is empty, this will be ignored.

Let us represent block queue by q.

(a)    Initially, x = 10, y = 2, q is empty.

          m.A() : line 1 : x++; x = 11
                       line 2 : c.signal : q empty : ignore signal
                       line 3 : y = x- 2; y = 11 - 2 = 9

           Now, x = 11, y = 9, q empty
           m.B() : line 4 : if (x > 10) : true as x = 11
                         line 5 : x--; x = 10

           Now, x = 10, y = 9, q empty
           m.B() : line 4 : if (x > 10) : false as x = 10
                         line 6 : c.signal : this process will be placed in q

           Now, x = 10, y = 9, q = (m.B())
           m.B() : line 4 : if (x > 10) : false as x = 10
                         line 6 : c.signal : this process will be placed in q

           Now, x = 10, y = 9, q = (m.B(), m.B())
           m.B() : line 4 : if (x > 10) : false as x = 10
                         line 6 : c.signal : this process will be placed in q

           Now, x = 10, y = 9, q = (m.B(), m.B(), m.B())
           m.A() : line 1 : x++; x = 11
                         line 2 : c.signal : run first m.B() from q : line 7 : x-- : x = 10

           Now, x = 10, y = 9, q = (m.B(), m.B())
           m.A() : line 1 : x++; x = 11
                         line 2 : c.signal : run first m.B() from q : line 7 : x-- : x = 10

            Final values will be x = 10, y = 9, q = (m.B())

         

Add a comment
Know the answer?
Add Answer to:
Exercise 4.4.1: Tracing a monitor execution. About While a process is executing inside the function A...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • QUESTION 1 Process P1 waits on the condition x in the monitor M. Process P2 calls...

    QUESTION 1 Process P1 waits on the condition x in the monitor M. Process P2 calls x.signal() within a function defined in the same monitor M. What further scenario is possible? (Check all that apply.) Process P2 is suspended. Process P1 resumes the execution. Process P1 resumes the execution. Process P2 continues the execution. Process P2 continues the execution. Process P1 is nonetheless suspended until P2 leaves the monitor. The operation x.signal() fails. QUESTION 2 The following pseudocode fragment adds...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT