Question

In: Computer Science

Answer the following: a) What is a critical region? b) How can counting semaphores be used...

Answer the following: a) What is a critical region? b) How can counting semaphores be used to provide exclusive access to a critical region? c) Describe the operation (clearly, in English) of the semWait and semSignal actions of a counting semaphore.

Solutions

Expert Solution

a) critical region - - critical region is also called as rejection region. It rejects the null hypothesis. It is a part of a program where the shared resources are accessed by different methods. Variables are accessed and multiple processes take place in critical region. In a critical region, when a process tries to execute the region statement, the boolean expression b is evaluated. If b is true, statement s is executed. If it is false the process is delayed until b becomes true and no other process is in the region associated with v.

b) semaphore - semaphore is an integer variable which can only be accessed through down and up. It is operating system resources implemented at kernel level. Semaphore operations are atomic. These are of two types

1. wait

2 signal

It takes only integer value.semaphores can also be used to solve various synchronization problems.

Types of semaphore

Counting semaphore (-infinity and+infinity) - it is used for giving control access to resources consisting of finite number Of instances.

Positive value indicates total no. Of successful down operations.

Negative value indicates no. Of processes blocked in blocking queue.

Binary semaphore(0,1)-- it deals with critical section problem. It provides mutual exclusion. It can range over between 0 and 1.

Counting semaphore - -

Struct csemaphore

{

Int value;

Queque L;

} ;

Down (shut csemaphore s)

{

S value = s value - 1;

If ( s value<0)

{

Put this process in S.L() &

Block it

}

}

Up (struct csemaphore s)

{

S.Value=s. Value+1;

If (s.Value <=0)

{

Wake up one of the blocked process

}

}

C) sem wait and sem signal operations:

in the sem _wait () we wait for the signal from another process. what we do is we will decrement the semphore variable value.

Wait(s)

{

While S<=0

// no-operation

S--;

}

Sem signal- in the sem signal, we increment the semaphore value. Only one process can modify the same semaphore value at a time.

Signal (s)

{

S++;

}


Related Solutions

What are Semaphores and Mutex? What are they used for?
What are Semaphores and Mutex? What are they used for?
Q3) Explain; how the synchronization mechanism (semaphores) can be used, to ensure a correct access to...
Q3) Explain; how the synchronization mechanism (semaphores) can be used, to ensure a correct access to exclusive resources.
a) What is double counting problem? How can it be solved? b) Describe the two sector,...
a) What is double counting problem? How can it be solved? b) Describe the two sector, three sector and four sector circular flow of GDP.
What does the alpha level signify? What is the critical region? What happens to the critical region if alpha increases/decreases?
    •Steps for hypothesis testing   •What does the alpha level signify? What is the critical region? What happens to the critical region if alpha increases/decreases? What effect does changing alpha have on your hypothesis test decision?   •Null and alternative hypotheses – what they are, how to construct them for all tests we’ve covered, and how they differ for one- vs two-tailed tests   •How to find the critical values for z, t (one- and two-tailed) and F....
Answer the following: 1a. What are the rules for counting significant figures? 1b. What are the...
Answer the following: 1a. What are the rules for counting significant figures? 1b. What are the rules of significant figures when multiplying or dividing numbers? 1c. What are the rules of significant figures when adding or subtracting numbers? 1d. What is the formula for an average? 1e. What is the formula for a standard deviation (assuming small sample size), also called the square root of the variance? 1f. How many significant figures should a standard deviation have? 1g. If you...
how well can Ovid the Poet be used as a historian of the region in his...
how well can Ovid the Poet be used as a historian of the region in his time?
A) What is quantitative easing, a term often used in the news? Answer: B) How is...
A) What is quantitative easing, a term often used in the news? Answer: B) How is the Fed different from the Treasury? And why were they separated in 1913, the year the Fed was created? Answer: C) How does expansionary monetary policy use open market operations to achieve its goal of economic stimulation (raising the RGDP)? Answer:
For the following exercises, assume that there are n ways an event A can happen...Use the Multiplication Principle of counting to explain how many ways event A and B can occur.
For the following exercises, assume that there are n ways an event A can happen, m ways an event B can happen, and that A and B are non-overlapping.Use the Multiplication Principle of counting to explain how many ways event A and B can occur.
A) What are opportunity costs and how can they be used to make good choices? B)...
A) What are opportunity costs and how can they be used to make good choices? B) Pretend that you are a good bass player and the Rolling Stones ask you to leave school, work, etc. and join them on tour for the next four months. What will the opportunity costs be of joining the Rolling Stones on tour? C) What will the opportunity costs be of not joining them on tour?
1) a. How can a galvanometer be used to determine emf in a circuit? b. What...
1) a. How can a galvanometer be used to determine emf in a circuit? b. What two factors determine the direction of the induced emf? c. When a bar magnet is thrust into one end of a coil, is the pole produced at the end of the coil the same as, or opposite to the pole of the bar magnet? Does the action of these two magnetic fields tend to oppose the motion of the bar magnet or assist it?...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT