[MUD-Dev] Event Scheduling

J C Lawrence claw at kanga.nu
Tue Feb 8 20:53:21 CET 2000


On Tue, 8 Feb 2000 19:17:54 -0700 
cg  <cg at ami-cg.GraySage.Edmonton.AB.CA> wrote:

> [J C Lawrence:]
>> Mine is written in C++, with a standard STL priority queue for
>> pending events in botht he Dispatchor and Executor, and short
>> circuit evaluation (ie never hits the priority queue) for those
>> incoming entries that are adjudged as being already ripe, or will
>> be ripe by the time they reach a waiting thread (if a thread is
>> ready).  This saves the (occassionally) non-trivial insertion
>> cost as well as lock contention on the queues.

> Do you handle any currently-ripe entries in the queue before any
> new tasks that are immediately ripe? You likely want to do that to
> avoid starvation in cases of server overload.

Detecting and handling ripe events on the queue and delivering
events to the queue (or directly to the Executor) is done by
seperate threads.  The executor _tends_ (not guaranteed and its not
alwsy true) to process events with equivalent priorities in receipt
order so "older" events that have been waiting for a thread will
tend to get devered before newly delivered events.

There's nothing in there that guarantees against starvation, but the
system tends to bleed away from starvation conditions by nature.

> Manipulation of that queue has never shown up in my profiling,
> however - it's time is tiny compared to actually executing the
> events.

I don't think I've noticed it either.  Certainly I've never looked
for it, or (more importantly) had cause to look for it.

--
J C Lawrence                                 Home: claw at kanga.nu
----------(*)                              Other: coder at kanga.nu
--=| A man is as sane as he is dangerous to his environment |=--


_______________________________________________
MUD-Dev maillist  -  MUD-Dev at kanga.nu
http://www.kanga.nu/lists/listinfo/mud-dev



More information about the mud-dev-archive mailing list