79 lines
2.3 KiB
TeX
79 lines
2.3 KiB
TeX
|
% HOMEWORK #2
|
||
|
% re: processes
|
||
|
%
|
||
|
\documentstyle[11pt,fullpage]{article}
|
||
|
\pagestyle{empty}
|
||
|
\begin{document}
|
||
|
|
||
|
\begin{center}
|
||
|
{\large\bf BACI Projects for an OS Course}
|
||
|
|
||
|
\end{center}
|
||
|
|
||
|
\begin{enumerate}
|
||
|
\item {\bf A's and B's:} For the following
|
||
|
program outline in Ben-Ari Concurrent Pascal,
|
||
|
\begin{tabbing}
|
||
|
xxxxxx \= xxx \= \kill
|
||
|
\> PROGRAM As\_and\_Bs; \\
|
||
|
\\
|
||
|
\> VAR \\
|
||
|
\>\> \{ semaphore declarations \} \\
|
||
|
\\
|
||
|
\> PROCEDURE A; \\
|
||
|
\> BEGIN (P's and V's only) END; \\
|
||
|
\\
|
||
|
\> PROCEDURE B; \\
|
||
|
\> BEGIN (P's and V's only) END; \\
|
||
|
\\
|
||
|
\> BEGIN \\
|
||
|
\>\> \{ semaphore initializations \} \\
|
||
|
\>\> COBEGIN A;A;A;B;B; COEND; \\
|
||
|
\> END.
|
||
|
\end{tabbing}
|
||
|
complete the program using {\it general} semaphores so that the
|
||
|
processes ALWAYS terminate in the order A (any copy), B (any copy), A
|
||
|
(any copy), A, B. In addition to the program,
|
||
|
hand in the results of FIVE executions of the
|
||
|
program using the -apt option.
|
||
|
Include an explanation (or proof, if you prefer) of why the
|
||
|
program works like it should.
|
||
|
|
||
|
\item {\bf Binary Semaphores:}
|
||
|
Repeat problem 1 using only BINARY semaphores. In addition, you
|
||
|
can use assignment, incrementing, and decrementing auxiliary INTEGER
|
||
|
variables, along with IF-(testing INTEGER expressions)-THEN-ELSE.
|
||
|
Consider why this problem can not be solved without counting
|
||
|
variables.
|
||
|
|
||
|
\item {\bf More A's and B's:}
|
||
|
Repeat the A and B problem using four concurrent processes
|
||
|
(A, A, A, and B) such that they terminate in the order A (any copy),
|
||
|
B, A, A.
|
||
|
|
||
|
\item {\bf Even More A's and B's:}
|
||
|
Repeat the A and B problem using eight concurrent processes (A, A, A, A,
|
||
|
B, B, B, B) such that they terminate in the order AABABABB. {\bf
|
||
|
Tough one!}
|
||
|
|
||
|
\item {\small\bf Busy Waiting versus Semaphores:}
|
||
|
Using the program developed in the
|
||
|
general semaphore project above (ABAAB), consider
|
||
|
the performance effect of its execution with your fair and
|
||
|
your unfair (random) semaphore implementations.
|
||
|
That is, calculate the total number of
|
||
|
busy waiting loops that occur in each implementation.
|
||
|
Compare the performance of these two semaphore implementations
|
||
|
with a busy waiting implementation, i.e., an implementation that
|
||
|
uses the exchange operation for synchronization. In each case,
|
||
|
use a large number of executions (say,
|
||
|
1000) to obtain better statistics.
|
||
|
Discuss your results, explaining why one implementation is preferred
|
||
|
over another.
|
||
|
|
||
|
|
||
|
\end{enumerate}
|
||
|
|
||
|
|
||
|
\end{document}
|