Question

QUESTION 13 Variable count=0 is shared between processes P0 and P1. P0 executes code count++;. P1...

QUESTION 13

  1. Variable count=0 is shared between processes P0 and P1. P0 executes code count++;. P1 executes code count--; P0 and P1 run concurrently, without any synchronization. Each process runs exactly once. What is the value of count after the execution of both processes?

1

0

-1 or 1

-1

-1, 0 or 1

QUESTION 14

  1. Six dining philosophers, fully aware of the potential deadlock (and death of starvation), enumerated their chopsticks 0 through 5 and agreed that a hungry philosopher always picks the odd-numbered chopstick and only then the even-numbered chopstick. What kind of deadlock handling strategy is this?

Deadlock avoidance

Deadlock prevention

Deadlock ignoring

Deadlock detection + resolution

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

Ques 13. Answer : (b) 0

The possible order in which the processes can run are

  • P0 -> P1

P0 : count++

count = count + 1 = 0+ 1

count = 1

P1 : count--

count = count - 1

count = 1 - 1

  count = 0

  • P1 -> P1

P1 : count--

count = count - 1

count = 0 - 1

  count = -1

P0 : count++

count = count + 1 = -1 + 1

count = 0

So, the value is same in all cases.

Ques 14. Answer ; (b)

Inn the given condition, then philosophers are picking in a way that a possible deadlock is avoided or prevented. So, it is Deadlock prevention.

Add a comment
Know the answer?
Add Answer to:
QUESTION 13 Variable count=0 is shared between processes P0 and P1. P0 executes code count++;. P1...
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
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
ADVERTISEMENT