[MUD-Dev] Re: [CODE] [LANGUAGE/PLATFORM SPECIFIC] My Event Engine

J C Lawrence claw at under.engr.sgi.com
Tue Aug 11 10:31:48 CEST 1998


On Fri, 17 Jul 1998 19:51:11 -0600 
Chris Gray<cg at ami-cg.GraySage.Edmonton.AB.CA> wrote:

> I didn't quite follow all of that, but I'll ask this question: where
> does your server spend its time waiting if it has nothing to do? 
> Mine spends its time in a single 'select' call, which contains the
> fd-bits for the main connection socket, and all client sockets. I'm
> not multi-threaded, so that is easy for me to do.

Did you note the performance concerns of select() vs poll() at:

   http://www.kanga.nu/~petidomo/lists/mud-dev/1998Q2/msg01208.html

?

--<cut>--

There is one thing to watch out for here: if you use select(2) in your
polling loop, be aware that the size of your FD array is equal to the
value of your largest FD. This is because select(2) uses a bitmask for
its FD array. This means one of your threads will want to poll FDs 991
to 1000.  Unfortunately, your FD array is still 1000 long. What's
worse, the kernel still has to do a minimal scan for all those 1000
FDs. The solution to this is to use poll(2) instead, where you only
have to pass as many FDs as you want to poll, and the kernel scans
only those.

--<cut>--

--
J C Lawrence                               Internet: claw at null.net
(Contractor)                               Internet: coder at ibm.net
---------(*)                     Internet: claw at under.engr.sgi.com
...Honourary Member of Clan McFud -- Teamer's Avenging Monolith...




More information about the mud-dev-archive mailing list