The purpose of this lab is to allow students to become comfortable with Multithreaded Programming using the POSIX Pthreads API.
FAQ
(submission instructions and other useful stuff)
There are several references for this labs
All work should be done on a machine in the department's Linux cluster. You can refer to ssh for more information on how to log into a remote machine.
TOTAL | 16 points |
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.Carefully 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.