22.8 Thread-worker Pool with Bounded Buffer

Team-FLY

22.8 Thread-worker Pool with Bounded Buffer

This section describes an implementation of a thread-worker pool that synchronizes on a bounded buffer containing client communication file descriptors. (See, for example, Section 16.5.) The server is a producer that places communication file descriptors in a circular buffer. The worker threads are consumers that wait for the communication file descriptors to become available in the buffer.

Write a worker_pool_buffer server that takes three command-line arguments: the listening port number, the size of the bounded buffer and the number of worker threads in the pool. The threads call the handle_request function to process the communication. Design and run experiments to answer the following questions.

  1. How does the connection time depend on the size of the bounded buffer? What factors influence the result?

  2. How does the number of worker threads influence the server response byte rate?

  3. How sensitive is overall performance to the number of worker threads?

  4. When does worker pool perform better than thread-per-request ?

Before running the experiments, write a discussion of how different experimental parameters might influence the results in each case.

Team-FLY


Unix Systems Programming
UNIX Systems Programming: Communication, Concurrency and Threads
ISBN: 0130424110
EAN: 2147483647
Year: 2003
Pages: 274

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net