Threads

From: George (greerga@CIRCLEMUD.ORG)
Date: 11/25/97


After some quick hacking...(process_io is a thread)

Tue Nov 25 20:59:12 :: process_io: Looping for input
Tue Nov 25 20:59:12 :: process_io: Found input
Tue Nov 25 20:59:14 :: process_io: Looping for input
Tue Nov 25 20:59:14 :: process_io: Found input
Tue Nov 25 20:59:19 :: Warning: process_io not responding for 5 seconds.
Tue Nov 25 20:59:20 :: nusage: 1   sockets connected, 1   sockets playing
Tue Nov 25 20:59:24 :: SYSERR: process_io not responding after 10 seconds...restarting.

...which included a deliberate 1-20 second delay per processing loop.

I basically took the huge chunk of code in game_loop between process_input
and process_output and put it into it's own function which becomes a
thread.

Restarting the thread seems to work as expected.  Normal processing is
nice, although choppy because I pause for 1 second with the sleep()
command.

After 5 seconds you get a warning, after 10 it kills process_io and starts
another one.  In the future I would like to add things such as 'last
command executed', 'vindictive erradication of socket', or simple 'evil
command removal and continue' features.

I can walk around without apparent problems although I know for a fact the
current code is not thread safe. (Think global buffers.)  I'll play around
with it some more and see if anything of use can be made of it with stock
code only.

Current configuration:

Main thread:
  Handles sending/receiving of input/output buffers.
  Kills and restarts the process_io thread if it is apparently locked in
        an infinite loop.  (There are many more graceful things I want to
        do in addition to this.)

process_io thread:
  Processes any input in descriptor, placing result in output buffer. (ie:
        actual player interaction and all those ACMD's)

 --
George Greer  -  Me@Null.net   | Genius may have its limitations, but stupidity
http://www.van.ml.org/~greerga | is not thus handicapped. -- Elbert Hubbard


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/08/00 PST