[MUD-Dev] Atomic functions

KevinL darius at bofh.net.au
Wed Nov 15 10:42:17 CET 2000


>>> "Felix A. Croes" wrote
> A few years ago, I posted to this list about my idea for atomic
> functions,
> 
>     http://www.kanga.nu/archives/MUD-Dev-L/1998Q2/msg00256.php
> 
> I have now implemented them in my server, and this posting concerns
> that implementation and the effects of atomic functions on MUDs.

Oh, that's cool ;)

Can I ask, because I started to look at the code, but it looks to be a fun 
thing to unravel, how it'd deal with the following (rather pathologic) bit of 
code?

if str < 10
    str = str * 3
else:
    str = str * 2

(using pythonic layout 'cause it's easier ;)

Say this is part of a spell, to raise someone's strength (to give it that nice 
muddy flavour).  It's cast by two people, A and B, on a third, C.  The 
timeslicing does the following, for some strange reason:

A: if str < 10
B: if str < 10
B:     str = str * 3
B: else:
B:     str = str * 2
A: str = str * 3
A: else:
A:     str = str * 2

I can't think my way around that working properly without locking - if you 
don't cache str, then str ends up way high (say it starts at 7, for interests' 
sake).  If you do cache, then it ends up lower than it should be for two casts 
- B's essentially gets ignored.  The only other alternative I could see was to 
cache all read values, and check, in C&C lockless manner, whether they'd 
changed or not every time they were accessed, which felt like a higher 
overhead.

> The server requirements for atomic functions are very similar to those
> for the C&C thread model.  The server must have its own internal
> virtual machine; VM threads must be finite in duration, and must run
> sequentially.

Does sequentially mean starting and ending one after the other?  If so, what 
do you gain from threads?  If not, how does it deal with the above, where 
there's not an explicit "failure" on anyone's behalf?

The planar description was nice, tho - that's a neat way to explain what 
happens, makes sense ;)

KL




_______________________________________________
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