This is the mail archive of the
ecos-discuss@sourceware.org
mailing list for the eCos project.
HTTP server and multiple threads
- From: Hans Hübner <hans dot huebner at junger-audio dot com>
- To: ecos-discuss at sources dot redhat dot com
- Date: Wed, 3 Aug 2005 14:05:14 +0200 (CEST)
- Subject: [ECOS] HTTP server and multiple threads
Hi,
I am currently developing a C++ http server for eCos. Even though it is a new
development, I'm looking at the built in http server for inspiration.
I have a question regarding its thread handling and select(): The builtin
http server can be built with multiple threads so that more than one request
can be served at the same time. This is implemented by first opening the
server socket, setting the local address and calling listen(). Then, a number
of threads is started, each with cug_httpd_server() as the thread function.
In cyg_httpd_server, each of the worker threads calls select() for the server
socket (only), calls accept if the server socket is ready and then starts
cyg_httpd_process() on the given file descriptor in order to actually process
the request.
This sequence of operations, even though looking consistent and elegent, seems
kind of unsual to me: Are multiple threads allowed to select on the same set
of file descriptors? If so, is there any guarantee that only one of the
selects will actually return once a file descriptor becomes ready? Is this an
eCos speciality, or is this common among multi threaded systems supplying
select() and friends?
Thanks for shading some light - I've grown up with 16 bit Unix and select, let
alone multi threading, never made it into my natural understanding of the API
:)
-Hans
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss