Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Figure 5.6 /* program mutualexclusion*/ const int n-/* number of processes */ semaphore s - 1; void P(int i) while (true) semWait (s)i /*critical section*

Figure 5.6

image text in transcribed

image text in transcribedimage text in transcribedimage text in transcribed

/* program mutualexclusion*/ const int n-/* number of processes */ semaphore s - 1; void P(int i) while (true) semWait (s)i /*critical section* semSignal(s); /* remainder; void main() parbegin (P(1), P(2), . . ., P(n)); Figure 5.6 Mutual Exclusion Using Semaphores 4 (5 points) Consider the following definition of semaphores: void semWait(s) if (s.count > 0)5 s.count--; else { place this process in s.queue; block; void semSignal (s) if (there is at least one process blocked orn semaphore s) f remove a process P from s.queue; place process P on ready list; else s.count+ Compare this set of definitions with that of Figure 5.6. Note one difference: With the preceding definition, a semaphore can never take on a negative value. Is there any difference in the effect of the two sets of definitions when used in programs? That is, could you substitute one set for the other without altering the meaning of the program? /* program mutualexclusion*/ const int n-/* number of processes */ semaphore s - 1; void P(int i) while (true) semWait (s)i /*critical section* semSignal(s); /* remainder; void main() parbegin (P(1), P(2), . . ., P(n)); Figure 5.6 Mutual Exclusion Using Semaphores 4 (5 points) Consider the following definition of semaphores: void semWait(s) if (s.count > 0)5 s.count--; else { place this process in s.queue; block; void semSignal (s) if (there is at least one process blocked orn semaphore s) f remove a process P from s.queue; place process P on ready list; else s.count+ Compare this set of definitions with that of Figure 5.6. Note one difference: With the preceding definition, a semaphore can never take on a negative value. Is there any difference in the effect of the two sets of definitions when used in programs? That is, could you substitute one set for the other without altering the meaning of the program

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2019 Wurzburg Germany September 16 20 2019 Proceedings Part 2 Lnai 11907

Authors: Ulf Brefeld ,Elisa Fromont ,Andreas Hotho ,Arno Knobbe ,Marloes Maathuis ,Celine Robardet

1st Edition

3030461467, 978-3030461461

More Books

Students also viewed these Databases questions

Question

1. Write down two or three of your greatest strengths.

Answered: 1 week ago

Question

What roles have these individuals played in your life?

Answered: 1 week ago

Question

2. Write two or three of your greatest weaknesses.

Answered: 1 week ago