Unix Systems Programming: Lab 9

Lab time:   No assigned lab time due to lab space construction.  Work at your own pace, but work.
Due:           Wednesday, December 8, 2010 @5:00 pm.


Purpose and Rationale

The purpose of this lab is to allow students to become comfortable with Multithreaded Programming using the POSIX Pthreads API.

Primary Resouces:

There are several references for this labs

If possible, you should ssh into the cluster to perform all lab activities.

Point Value

Lab9 is worth 25 points, five of those points are for correct submission.

Lab 9 : Pthreads

Project

Your code for Lab 8 was designed to support multiple clients, but one client at a time. You kept clients waiting until your server finished handling the current client. In this lab you will extend your spell-checker to support multiple clients at the same time.

Your server should be able to support multiple client's simultaneously. We will test that it correctly handle up to three client's simultaneously.

Unless you use synchronization mechanisms (such as semaphores) you must take care not to have shared variables among your threads which require they change the value of the variable.

Makefile

One complication with using threads is accesssing the correct thread library. You will find a same Makefile in the Butenhof example. We will not be using the default pthread library on our Linux cluster, so we will need to specify the location of the header files and libraries, when compiling our code for the server program. You'll need the following lines in your Makefile:

LDFLAGS=-static -Wl,-rpath=/opt/glibc/glibc-2.2.2/lib
INCLDIR=-I/opt/glibc/glibc-2.2.2/include
LIBDIR=-L/opt/glibc/glibc-2.2.2/lib
LIBS=-lpthread

.c:
      ${CC} ${LDFLAGS} -o $@ $@.c ${LIBDIR} ${INCLDIR} ${LIBS}


What you are including is as follows:

  1. LDFLAGS :   Specify you want to use the static library, and places the directory the thread library we are using on the linker's path.
  2. INCLDIR :   This is the directory where the header files for the threads library are located.
  3. LIBDIR :   This is the directory where the threads library is located.
  4. LIBS :   This is the threads library we are going to use
  5. .c: :    This is a suffixing rule which specifies are to build your object code from a C file.

Deliverables

Follow the procedure carefully, correct delivery of your work is worth 5 points. Follow the 4 steps below.

  1. Create a directory:
           username.lab9
  2. This directory will contain:
  3. When you are finished with your assignment you will create a compressed archive file using tar (this utility stores your directory as a single file, then compresses its size.)
           tar -czvf   username.lab9.tgz   username.lab9
  4. You will email your file to our grader as an attachment. I will send an aknowledgement that your assignment has been recieved.

  5. To  bsm@cs.uchicago.edu
    Attachment  username.lab9.tgz
    Subject  CSPP51081