Assignment

You are to write a program called bouncer.c that demonstrates your understanding of POSIX threads programming in C. The program will move words across the screen. All words (up to a maximum of 12) are supplied on the command line. When a word reaches the edge of the screen it "bounces" i.e. it starts moving in the opposite direction. Similarly, when the user presses the 'b' key all words bounce and start moving in the reverse direction. Each word moves at a different speed. The speed is random and assigned when the program starts up. When functioning properly the program should work like this.

Approach

Getting started

You have access to a solution to the bounded buffer problem here. This code will be a help since your approach to solving the bouncing words problem is based on multiple producers (word threads produce move requests) and a single consumer (the coordinator thread processes move requests). This code also shows you how to get started with POSIX threads programming.

This program shows you how to advance a single word across the screen using a thread to do so. Note however that this code provides only a starting point and will require significant modification in order to solve the bouncing words problem in the way described above. To compile and run this program you must use gcc and link against the pthread and ncurses libraries (as shown in the video above).

Deliverables

You are required to deliver the following in text files:

Provide a description of how your software fits together in description.txt. This document should include an overview of what each thread does and any synchronisation issues it faces and how they are handled. You can use the Linux 'wc' command to count the number of words in your text files. Where files exceed the word limit a mark of zero will be awarded for the assignment.

In problems.txt write an explanation of any shortcomings or weaknesses in your solution. Failure to list any shortcomings indicates you were not aware of them and significant marks will be deducted accordingly.

All code must be neatly tabulated, well-structured and commented. Marks are awarded for solving the problem, solving it elegantly and demonstrating your understanding of the problems/solutions through comments.

What's it worth?

15% of your overall mark.

Do I have to work in a team?

Yes. Only submissions by teams of two or three people are acceptable. Single submissions or submissions from teams with more than three members will not be marked.

Can I borrow code from elsewhere?

Any use of the work of others must be specifically acknowledged. See our policy on plagiarism.

FAQ

Q. I cannot find a partner for the project. What should I do?
A. E-mail me as soon as possible and I'll try to find you one. If you leave e-mailing me too late I will not accept your submission and you will receive a mark of zero.

Q. I am not a registered CASE3 student (e.g. I am an Erasmus student) and am taking this module. Do the usual delivery instructions (see below) apply to me?
A. No. Tar your solution and e-mail it to me by the due date.

Q. I was sick over the period we had to work on the assignment. What can I do?
A. Submit a doctor's note to the faculty office and to me covering you for the period in question. The programme board will then make a decision regarding your eligibility to repeat over the summer.

I have a different question

E-mail me.

How to submit

Create the following directory off one team member's Linux home directory:

~/ca321/assignment01 (note the zero)

Place all deliverables in this directory. Each file must contain the names and ID numbers of those students responsible for producing it. The contents of this directory will be automatically collected immediately the deadline expires. You will lose write permission on the directory at this time. Also, a file named collected will appear in the directory and serves as a verification that your assignment was successfully collected. If it does not appear, your assignment was not successfully submitted.

It is your responsibility to ensure the directory exists only in one team member's account, is correctly named (directory and filenames are case sensitive) and contains your solution to the assignment. Failure to comply with any of these requirements will result in an automatic mark of zero. To create the directory enter the following in a command shell:

Deadline

Your files will be collected from the above directory at 18:00 Monday 9 November 2009.