Homework Two

Due : Tuesday March 11, 2008

Assignment:

  1. Write a Posix thread program to implement the Floyd and Steinberg Error Diffusion Algorithm using the Multithread Multirow error diffusion method described in the lectures.
  2. Modify the matrix-multiplication algorithm matrix_threads.c or write one from scratch which takes the number of threads to use as an input and partitions the work in the most efficient manner to accomplish the multiplication with this number of threads. Explain your justification for the choice of method.
  3. Modify twordcount4.c to handle more than two files on the command line and to create a thread for each file.
  4. Modify the message animation program tanimate.c by isolating all the calls to screen-control functions in a new thread. The other threads send requests to the screen-control thread (SCT) to put text on the screen using a structure containing the row, column, and the string to be rendered. The logic should be similar to the wordcount program in that one needs a variable to hold the messages, a mutex to prevent corruption, and a condition-variable to be used to signal the SCT that an animation thread has deposited a message.
    Note that this design makes it easy to generalize the program to use a GUI for display or to speak to a remote server.

This assignment is an individual assignment, to be done on your own without help from other students in the class. However, you may use any materials from any written resource, including web resources.