• edited by
1,669 views
0 0 votes

Consider the methods used by process $P_{1}$ and P2 for accessing their critical sections whenever needed, as given below. The initial values shared Boolean variables, $\mathrm{S}_{1}$ and $\mathrm{S}_{2}$ are random assigned..
\begin{tabular}{|l|l|}
\hline Method used by $\mathrm{P}_{1}$ & Method used by $\mathrm{P}_{2}$ \\
\hline do & do \\
\hline 1 & 1 \\
\hline flag $[/]=$ True;
\[
S_{1}=S_{2}
\] & flag $[j]=$ True;
\[
S_{1}=S_{2}+1 ;
\] \\
\hline & \\
\hline & \\
\hline ) while(1); & ) while(1): \\
\hline
\end{tabular}

For the program to guarantee mutual exclusion, the predicate P and Q in the while loop should be
a.
$\mathbf{P}$ : Flag $[J]=$ true and $\mathrm{S}_{1}!=\mathrm{S}_{2}$
Q : Flag $[t]=$ true and $\mathrm{S}_{1}==\mathrm{S}_{2}$
b.
$\mathbf{P}:$ Flag $[\eta]=$ true and $\mathrm{S}_{1}==\mathrm{S}_{2}$
$\mathbf{Q}:$ Flag $[t]=$ true and $\mathrm{S}_{1}!=\mathrm{S}_{2}$
$\mathbf{P}$ : Flag $[t]=$ true and $\mathrm{S}_{1}!=\mathrm{S}_{2}$
c.

Q : Flag $[\lambda]=$ true and $\mathrm{S}_{1}=-\mathrm{S}_{2}$
$\mathbf{P}$ : Flag $[t]=$ true and $\mathrm{S}_{1}==\mathrm{S}_{2}$
d. $\mathbf{Q}$ : Flag $[J]=$ true and $\mathrm{S}_{1}!=\mathrm{S}_{2}$

2 Answers

Position:
Show:

Related questions

3 3 votes
1 1 answer
1.7k
1.7k views
Vishal Goyal asked Dec 2, 2016
1,715 views
Assume 2 processes computer ( ) and science ( ) that are concurrent and that the three semaphore mutex,Q and R initialized to 1 are shared between the two processes. Q is...
0 0 votes
0 0 answers
523
523 views
legacy asked Nov 27, 2022
523 views
At the end of chapter 2, we studied a solution to the readers and writers problem, given below:-In this solution, as long as one reader is having the resource any new rea...
2 2 votes
1 1 answer
152
152 views
GO Classes asked Aug 26
152 views
Consider an integer semaphore $\texttt{S}$.Method $\textbf{1}$wait(S): disable interrupts while S <= 0: do nothing S = S - 1 enable interrupts signal(S): disable interrup...
3 3 votes
2 2 answers
141
141 views
GO Classes asked Jul 29
141 views
Which of the following statements are correct?Semaphore $\texttt{wait()}$ and $\texttt{signal()}$ operations must be atomic. A counting semaphore can represent the number...