CS 3304
Homework Assignment 5
Given: July 30, 1997 Due: August 6, 1997
The point value of each problem is shown in [ ]. The assignment must be received by the beginning of class on August 6, 1997. Note that this is a Wednesday. The deadline for late submissions remains 5:00 PM on August 6, 1997.
When the problem asks for an explanation, give a clearly written justification of your answer.
Two books on Ada have been placed on reserve in Newman library for your reference:
QA76.73 A16 R43 1983b
-- Reference Manual for the Ada Programming Language;
andQA76.73 A16 B87 1985
-- Concurrent Programming in Ada.
A particular Ada program models two commodities,
known as red and blue.
There are producer and consumer tasks that produce and consume
these commodities as follows:
producer1
always produces three red's and one blue
at a time;producer2
always produces one red and three blue's
at a time;consumer1
always consumes five red's and two blue's
at a time;consumer2
always consumes three red's and five blue's
at a time;
andconsumer3
always consumes four red's and four blue's
at a time.
Implement one or more Ada tasks to accomplish the buffering required by the above producer/consumer problem. Give a scenario in which your solution deadlocks. Explain how to avoid that deadlock.
Assume a program written in Ada
has three tasks,
searcher, builder, and printer,
that are written to loop forever,
each doing its own specialized job.
Of course,
an exception may cause one of these tasks to exit prematurely.
You are to add a new task watcher to the program
that also loops forever
and that checks up on the health of each task
every minute or so
(see the Ada delay statement in section 9.6
of the reference manual).
If a task has failed,
then watcher restarts it.
When the Ada run time system is unable to start up a task
or when a rendezvous fails for any reason,
it raises the TASKING_ERROR exception.
Use Ada exception handling to implement
the watcher task,
and explain what changes need to be made to
searcher, builder, and printer
to accommodate the watcher function.
If there are any limitations to your solution,
point those out.
Chapter 14, Problem 5.
Chapter 14, Problem 7.
This document was generated using the LaTeX2HTML translator Version 96.1 (Feb 5, 1996) Copyright © 1993, 1994, 1995, 1996, Nikos Drakos, Computer Based Learning Unit, University of Leeds.
The command line arguments were:
latex2html -split 0 -t CS 3304 Homework Assignment 5 homework5.
The translation was initiated by cs3304sm class account on Wed Jul 30 13:38:09 EDT 1997