Find Jobs
Hire Freelancers

Multi-thread web server in C

$250-750 USD

Cancelled
Posted almost 8 years ago

$250-750 USD

Paid on delivery
you will be developing a network application program that illustrates the client-server computing model. You are asked to write a real, working web server under the Linux operating system. To simplify your work, we have provided you with the C code for a very basic web server. This basic web server uses a single-threaded architecture to perform the required work, where the web server process will receive one user request at a time and serve it before accepting any new requests. Your job in this project is to make the web server more efficient by changing the way it handles the received requests. Your new web server shall use a multi-threaded architecture where the main thread receives new requests and inserts them into a waiting list, and a scheduling thread removes a request from the list and assigns it to a worker thread. The provided basic web server can handle some type of files HTML, GIF, JPEG, TXT, etc. It can also handle a limited portion of the HTTP web protocol (namely, the GET command to fetch a web page). You are not required to change that. The provided pieces of code are designed to help you concentrate on the required changes only. The parts of code that handle the interpretation of the text string(s) received in the request, logging functions, sending back the response string(s) and the requested target are provided to you in a compiled object file, while the parts that require change are provided to you in source files. Objectives: A web server has many of the problems you studied in the operating systems course, but it is easier to understand, modify and test a web server code than modifying and testing the code of a real operating system. In this project you are going to gain hands-on experience in the following areas: • Modifying an existing code base. • Creating and synchronizing cooperating processes and threads in Linux. • Setting up client-server inter-process communication using Internet sockets. • Applying some scheduling and overload handling strategies to improve system performance. • Using a benchmarking tool to measure the system performance. Multi-threaded Design: A better approach is to create a new worker thread for each client to serve his/her request. With this approach, each request can be responded-to, independently and once it is finished, that thread is terminated. If new worker threads could not be created for the incoming HTTP requests, then those requests will need to be buffered until new threads are created. In your implementation, you must have a master thread, a scheduling thread and worker threads. Master Thread: 1. The master thread is responsible for accepting new HTTP connections over the network and placing their descriptors in a fixed-size buffer. 2. The master thread should not read from any connection, it must immediately return to accepting more connections. 3. If the buffer is full, the master thread must follow the specified overload handling policy. Scheduling Thread: 1. It acts as a consumer from the buffer. 2. The scheduling thread, repeatedly, attempts to create a new worker thread. 3. If it succeeded, then it applies the specified scheduling policy, described below, to select the HTTP request that should be removed from the buffer and sent to the new worker thread. Worker Thread: 1. Each worker thread must be able to handle only static requests. 2. Once a worker thread is activated, it should call the serve() function with the network descriptor it gets from the scheduling thread. 3. The worker thread terminates after it finishes serving the HTTP request. Note that the master thread and the scheduling thread are in a producer-consumer relationship and require that their accesses to the shared buffer be synchronized. Specifically, the master thread may block and wait if the buffer is full; the scheduling thread must block and wait if the buffer is empty. In this project, you are required to use semaphores for synchronization.
Project ID: 10264269

About the project

Remote project
Active 8 yrs ago

Looking to make some money?

Benefits of bidding on Freelancer

Set your budget and timeframe
Get paid for your work
Outline your proposal
It's free to sign up and bid on jobs

About the client

Flag of SAUDI ARABIA
Jeddah, Saudi Arabia
5.0
1
Member since Apr 19, 2016

Client Verification

Thanks! We’ve emailed you a link to claim your free credit.
Something went wrong while sending your email. Please try again.
Registered Users Total Jobs Posted
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Loading preview
Permission granted for Geolocation.
Your login session has expired and you have been logged out. Please log in again.