[MUD-Dev] Re: [CODE] [LANGUAGE/PLATFORM SPECIFIC] My Event Engine
Chris Gray
cg at ami-cg.GraySage.Edmonton.AB.CA
Fri Jul 17 19:51:11 CEST 1998
[Todd Lair:]
>Now, as far as the polling for both types of sockets, I'm wondering if there isn't a more
>efficient way than what I'm doing. What I'm doing is using select, however, I'm only
>setting the single bit for the the descriptor in question for all three fd_sets. This seems
>like a big mistake to me, since I imagine, as the descriptors get larger in number, that the
>select call has to see if each bit is set for the lower descriptor numbers till it gets to the
>single set one.
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.
What is it that "ripens" your events to trigger the polling? In general
polling (as opposed to calling the 'poll' SysV socket call), is a bad
idea, since your CPU is busy doing things without accomplishing much.
Polling is used in some circumstances in order to get the absolute
minimum latency, but that is usually in situations where the CPU is
dedicated, or when what it is waiting for is guaranteed to be ready in
a very short period of time.
My goal is that when there is nothing for my server to do, it will use
no CPU time at all. Now, the NPC's will be doing things, but in the
intervals when none of them is active, the server should be idle.
All my beliefs, anyway!
--
Chris Gray cg at ami-cg.GraySage.Edmonton.AB.CA
More information about the mud-dev-archive
mailing list