% HOMEWORK #2 % re: processes % \documentstyle[12pt,fullpage]{article} \pagestyle{empty} \begin{document} \begin{center} {\large\bf BACI Project for an OS Course} \end{center} \vspace*{0.3in} This is problem 6.16 on page 213 of the textbook, made specific to Ben-Ari Concurrent Pascal. Write a program containing a monitor {\bf AlarmClock}. The monitor must have an integer variable {\bf theClock} (initialization to zero) and two procedures: \begin{itemize} \item PROCEDURE {\bf Tick}; \\ increments {\bf theClock} each time that it is called. It can do other things, like SIGNALC, if needed, but no WAITCs. \item PROCEDURE {\bf Alarm}({\bf id} : INTEGER; {\bf delta} : INTEGER); \\ blocks caller having identifier {\bf id} for at least {\bf delta} ticks of {\bf theClock}. \end{itemize} You may endow the monitor with any other variables that it needs. The monitor should be able to accommodate up to 5 simultaneous alarms. The main program should have two procedures outside of the monitor: \begin{itemize} \item PROCEDURE {\bf Ticker}; \\ calls {\bf Tick} in a repeat-forever loop. \item PROCEDURE {\bf Thread}({\bf id} : INTEGER; {\bf myDelta} : INTEGER); \\ calls {\bf Alarm} in a repeat-forever loop. \end{itemize} The main program cannot have any variables. The main program should start 4 concurrent threads: {\bf Thread(100,3)}, {\bf Thread(200,7)}, {\bf Thread(300,10)}, and {\bf Ticker}. Output should occur for each of the following events: \begin{enumerate} \item At each clock tick, show the values of {\bf theClock}. \item When any thread either waits or reawakens from a wait, show the id of the thread, the name of the condition on which it is waiting, and the time ({\bf theClock}) at which the wait occurs. \item When a condition is signalled, show the name of the condition being signalled and the time at which the signal occurs. \end{enumerate} Hand in a listing of the program and output showing each {\bf Thread} copy enduring at least one alarm cycle. You may find the {\bf tee} command helpful in this regard. \end{document}