Unix Systems Programming: Lab 9 - pThreads
Due: Friday, March 10, 2017 @ 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:
FAQ
(submission instructions and other useful stuff)
There are several references for this labs
- Lecture 9 is the primary reference for this lab
- Kerrisk, A Linux and UNIX System Programming Handbook, Chapters 29-33, 51
- Butenhof, Programming with POSIX Threads,
Chapters 1-5
and 8
- Molay, Understanding Unix/Linux Programming, Chapter 14
Provides an example of a web server which is implemented using threads.
- Course FAQ
page has
several links to online resources and examples of using threads.
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.
Marks Distribution
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 will set-up the socket and wait for clients
- When a client is recieved your server will create a thread
to
handle the client's request.
- The server will continue to wait for new client requests.
- The thread will handle its client's request then exit.
Your server should be able to support multiple client's simultaneously.
We will test
that it correctly handles up to three client's simultaneously.
You should use synchronization mechanisms (such as mutexes) to protect any shared data you might use.
Building
Be sure to confirm that your environment is configured
correctly. In general, to build pthread code on linux, you simply
use the -pthread flag, as in:
gcc -pthread -o my_thread my_thread.c
You can use test by building the samples included in the following:
- You will find a sample
Makefile
in Butenhof.
- You will also find samples in the Kerrisk code located in
~mark/pub/51081/kerrisk.code/
.
Deliverables
Carefully follow the 4 steps below.
- Create a directory:
lab9
- This directory will contain:
- All C files needed to build your client and server.
Your client can be exactly the same as you used in Lab 8.
- A file named
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.
- There should be no object files or executable files in
your
submission. Please make sure that all back-up files generated by emacs
(*~) are removed.
- When you are finished with your directory 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
- You will email your file to our TA as an attachment. He will send an
acknowledgement that your assignment has been
received.
To |
Nicholas Flees
(nickflees@uchicago.edu) |
Attachment |
username.lab9.tgz |
Subject |
CSPP51081-lab9 |