Question

If someone could help provide a detailed explanation for this please. There are similar posts but the explanations are a bit hard to understand.

Exercise 3 Consider m updater processes and n browser processes concurrently accessing a database in a multiprogrammed operat

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

1)
if updater is updating, this means s_db is 0, and P(s_db) will result in wait. So browser process will be blocked in the if condition if(count==1) which is in s_count semaphore

2)
We can see that the first browser that will browse will call P(s_db) and set count = 1. Now all this happens inside first P(s_count) and V(s_count). We can see that the semaphore isn't on hold for any browser process (means it is released after updating count). This means that multiple browser can pass P(s_count) and browse simultaneously

3)
for updater process, we have a binary semaphore s_db which will be held back by first updater process. So only one updater can access at once

4)
This isn't necessary. Assume browser process 1,2,3,4 (arrives in same order). 1 will set count to 1 and call P(s_db) and let them leave in order 1,2,3,4. This time 4 will set count to 0 and call V(s_db)

5) This solution is definitely free of deadlock since multiple browser process can read db at once but only one updater can update it (see part a,b,c for explanation). There can be situation where there are huge number of browser process and they arrive,leave and then arrive again before count drops to 0. which means that the s_db semaphore is always 0. so updater process will wait indefinitely if not starve

6)
This would result in inconsistency. Consider 2 broser process access count variable simultaneously (which was 0) now both increment it and it become 2. so the if condition will not execute and s_db remains 1 which allow updater process to update db while browser process was reading db. I am assuming the context switch between the processes at the line count++


answered by: ANURANJAN SARSAM
Add a comment
Answer #2

1)
if updater is updating, this means s_db is 0, and P(s_db) will result in wait. So browser process will be blocked in the if condition if(count==1) which is in s_count semaphore

2)
We can see that the first browser that will browse will call P(s_db) and set count = 1. Now all this happens inside first P(s_count) and V(s_count). We can see that the semaphore isn't on hold for any browser process (means it is released after updating count). This means that multiple browser can pass P(s_count) and browse simultaneously

3)
for updater process, we have a binary semaphore s_db which will be held back by first updater process. So only one updater can access at once

4)
This isn't necessary. Assume browser process 1,2,3,4 (arrives in same order). 1 will set count to 1 and call P(s_db) and let them leave in order 1,2,3,4. This time 4 will set count to 0 and call V(s_db)

5) This solution is definitely free of deadlock since multiple browser process can read db at once but only one updater can update it (see part a,b,c for explanation). There can be situation where there are huge number of browser process and they arrive,leave and then arrive again before count drops to 0. which means that the s_db semaphore is always 0. so updater process will wait indefinitely if not starve

6)
This would result in inconsistency. Consider 2 broser process access count variable simultaneously (which was 0) now both increment it and it become 2. so the if condition will not execute and s_db remains 1 which allow updater process to update db while browser process was reading db. I am assuming the context switch between the processes at the line count++

Add a comment
Know the answer?
Add Answer to:
If someone could help provide a detailed explanation for this please. There are similar posts but...
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
  • pleasw answer as soon as possible . this is for my exam practice . please read...

    pleasw answer as soon as possible . this is for my exam practice . please read the code and answer the question In a system, there are multiple reader processes which read from a shared file and multiple writer processes which update a shared file. The following variables are shared among all processes: int readCounter; semaphore mutex, writeLock; Reader and writer processes are given in the following C++-like pseudo programs: Reader Process // Non-Critical Section P(mutex); Writer Process // Non-Critical...

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