The purpose of this lab is to allow students to become comfortable with Multithreaded Programming using the POSIX Pthreads API.
There are several references for this labs
Lab9 is worth 25 points, five of those points are for correct submission.
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.
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.
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:
LDFLAGS
: Specify you want to use the
static library, and places the directory the thread library we are
using on the linker's path. INCLDIR
: This is the directory where
the header files for the threads library are located. LIBDIR
: This is the directory where
the threads library is located.LIBS
: This is the threads library we
are going to use .c:
: This is a suffixing rule which
specifies are to build your object code from a C file.Follow the procedure carefully, correct delivery of your work is worth 5 points. Follow the 4 steps below.
Makefile
, which will build both
your client and server, when make
is entered on the
command line. In addition, your make file must contain a target clean
which will remove all executables created by make when make
clean
is entered on the command line.To | bsm@cs.uchicago.edu |
Attachment | username.lab9.tgz |
Subject | CSPP51081 |