Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The following is a solution to design and implement a General Semaphore . Is Line 10 while(!s.hold); necessary? Please use one example to explain. Implementing

The following is a solution to design and implement a General Semaphore. Is Line 10 while(!s.hold); necessary? Please use one example to explain.

Implementing the General Semaphore

struct semaphore {

int value = ;

boolean mutex = FALSE;

boolean hold = TRUE;

};

shared struct semaphore s;

P(struct semaphore s) {

L1 while(TS(s.mutex)) ;

L2 s.value--;

L3 if(s.value < 0) {

L4 s.mutex = FALSE;

L5 while(TS(s.hold)) ;

}

else

L6 s.mutex = FALSE;

}

V(struct semaphore s) {

L7 while(TS(s.mutex)) ;

L8 s.value++;

L9 if(s.value <= 0) {

L10 while(!s.hold) ;

L11 s.hold = FALSE;

}

L12 s.mutex = FALSE;

}

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

Systems Analysis And Synthesis Bridging Computer Science And Information Technology

Authors: Barry Dwyer

1st Edition

0128054492, 9780128054499

More Books

Students also viewed these Databases questions

Question

Why is the System Build Process an iterative process?

Answered: 1 week ago