Up to Main Index                               Up to Journal for May, 2012

                      JOURNAL FOR SATURDAY 5TH MAY, 2012
______________________________________________________________________________

SUBJECT: Slowly I progress, then rewrite everything - again
   DATE: Sat May  5 17:28:00 BST 2012

This week has been very busy with work and I only had a little time to work on
the new WolfMUD. In the time I have had I have been concentrating on locking
issues and concurrency. That and networking.

Why those two areas specifically?

Well concurrency is the hardest bit to get right in any program and WolfMUD is
no different. Does simply using Go's channels, goroutines and the 'sync',
'sync/atomic' packages solve the problems? No, they are just tools for solving
the problem. A problem which I solved in the Java version of WolfMUD quite
well - hundreds of thousands of threads for players, mobiles and the worlds
itself with thousands of objects and locations. The server could run for years
and not a single deadlock. Trumpet blowing? We will see, question now is can I
do it again :)

I didn't realise it the time but the WolfMUD solution is similar to Dijkstra's
resource hierarchy solution[1] with the hierarchy in WolfMUD being based on
the memory address of the objects being locked and always locking lowest to
highest. To grab an additional resource WolfMUD required resources to be
released and acquired again. This is mostly done in:


  wolf.utilities.multiLockCommandProcessor.java
  wolf.world.commandProcessStatus.java


A nice reference I've since found is Allen B. Downey's "The Little Book Of
Semaphores"[2] which is an interesting read.

Networking I'm working on because it is the only way to interact with WolfMUD.
There is nothing worse than connections that keep dropping or when they do and
you reconnect to be told your player is already in use! You also don't want
resources kept when players disconnect - connect and disconnect a few thousand
times and you'll find all your memory has been used or you have thousands of
network connections and zombied players! Even a MUD can suffer from a DOS
attack :(

Looking at what I need to do to solve concurrency issues I might need to
rethink and rewrite what I have already implemented so far. This is not a bad
thing. The project is doing EXACTLY what I hoped it would - causing me to
think, write code, research, read and most importantly learn. For far too long
my brains have been addled and eaten day after day working with PHP and
creating yet another web page - notice no PHP was inflicted on anybody
creating this site!

--
Diddymus

  [1] https://en.wikipedia.org/wiki/Dining_philosophers_problem#Resource_hierarchy_solution

  [2] https://greenteapress.com/semaphores/LittleBookOfSemaphores.pdf


  Up to Main Index                               Up to Journal for May, 2012