[Home] [Groups] - Message: [Prev in Group] [Next in Group]

nu.kanga.list.mud-dev

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

[Full Header] [Plain Text]
From: J C Lawrence <claw@under.engr.sgi.com>
Newsgroups: nu.kanga.list.mud-dev
Date: Tue, 11 Aug 1998 10:31:48 -0700
References: [1]
Organization: Kanga.Nu
On Fri, 17 Jul 1998 19:51:11 -0600 
Chris Gray<cg@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@null.net
(Contractor)                               Internet: coder@ibm.net
---------(*)                     Internet: claw@under.engr.sgi.com
...Honourary Member of Clan McFud -- Teamer's Avenging Monolith...