Assignment4 - CSci4061 Programming Assignment 4 Specication...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
CSci4061 Programming Assignment 4 Specifcation Multi-Threaded Web Server with Caching Due at 10pm on 19th April 2010 1 Overview The purpose of this lab is to construct a multithreaded web server using POSIX threads (pthreads) in C to learn about thread programming and synchronization methods. Your web server will be able to handle any type of Fles HTML, GI±, JPEG, TXT, etc. It will handle a limited portion of the HTTP web protocol (namely, the GET command to fetch a web page). We will provide pieces of code (some already compiled into object Fles, and some source) that will help you complete the lab. Do not be overwhelmed - we have simplifed this assignment For you. Read the whole specifcation beFore starting. 2 Description Your server will be composed of three di²erent types of threads: dispatcher threads, worker threads and prefetcher threads. The purpose of the dispatcher threads is to repeatedly accept an incoming connection, read the request from the connection, and place the request in a queue for a worker thread to pick up and serve, in a loop. We will assume that there will only be one request per incoming connection. The purpose of the worker threads is to monitor the request queue, pick up requests from it and to serve those requests back to the client. Worker threads also put those requests back to another prefetching queue which will be read by the prefetcher threads. Prefetcher threads will then check if they can guess what the next request is going to be and bring the guessed page from the disk to the cache. Be careful to synchronize these two bounded queues. You will use the following functions which have been pre-compiled into object Fles that we have provided: void init(int port); // run ONCE in your main thread // Each of the next two functions will be used in order, in a loop, in the // dispatch threads: int accept_connection(void); int get_request(int fd, char *filename); // These functions will be used by the worker threads after handling the request int return_result(int fd, char *content_type, char *buf, int numbytes); (or int return_error(int fd, char *buf);) // For the prefetcher thread int nextguess(char *filename, char *guessed); ±ull documentation of these functions has been provided in util.h . More will be said below about how to use these functions. 3 Incoming Requests An HTTP request has the form: GET /dir1/subdir1/. ../target file HTTP/1.1 where /dir1/subdir1/. ../ is assumed to be located under your web tree root location. Our get request function automati- cally parses this for you and gives you the /dir1/subdir1/. ../target file portion and stores it 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
in flename parameter. Your web tree will be rooted at a specifc location, specifed by one oF the
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 4

Assignment4 - CSci4061 Programming Assignment 4 Specication...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online