[MUD-Dev] Re: TECH: Distributed Muds
Derek Snider
derek at idirect.com
Thu Apr 26 17:00:07 CEST 2001
>From Christopher Kohnert, April 26, 2001 3:53 PM
> You know, I've been curious. I've tried to get that sort of idle
> time in some prototype servers I've implemented. Granted, I have a
> sort of nasty requirement in that my 'tick' needs to be in 1/100th
> of a second. I've done a blocking select on the sockets but found
> the latency for commands entered on any of the sockets to be too
> unbearable. My question is how you achieve a 90% idle rate with any
> sort of responsive sockets. Perhaps a simple usleep() with no actual
> blocking select? I'm just curious because I've found that anything
> other than a tight non-blocking polling loop is just 'laggy'.
Servers in the DikuMUD family have a 1/4 second pulse rate. Basically
the main loop of the server grabs the current time (in milliseconds),
processes its current set of duties (user commands, NPC movement,
battles, etc), then grabs the current time to get the difference.
This difference is subtracted from a 1/4 second, and then the select()
call is used to delay for the leftover time (if any).
A blocking select would make it so your server would only be able to
do anything when it receives a command... and would not be able to do
any other tasks -- unless it was multi-threaded.
You need it to be non-blocking, with a small delay in your main loop.
_______________________________________________
MUD-Dev mailing list
MUD-Dev at kanga.nu
https://www.kanga.nu/lists/listinfo/mud-dev
More information about the mud-dev-archive
mailing list