[MUD-Dev] Re: atomic functions
J C Lawrence
claw at under.engr.sgi.com
Tue May 5 16:21:59 New Zealand Standard Time 1998
On Thu, 30 Apr 1998 03:59:20 +0200 (MET DST)
Felix A Croes<felix at xs1.simplex.nl> wrote:
> Having recently completed the implementation of the generic parsing
> utility that I posted about earlier, I am now preparing to convert
> my server to the lockless multithreading paradigm put forward on
> this list by J.C. Lawrence.
Note: I haven't had a chance to follow the subsequent posts in this
thread in great detail. Apologies for any re-hashing.
> It has occurred to me that the commit-or-fail idea can be applied to
> parts of threads as well as entire threads, leading to the following
> concept of "atomic functions":
> An atomic function is a function that succeeds or fails as a
> whole. Any runtime error that is not caught within the function
> will lead to the entire function call, with all its effects and
> side-effects, being undone.
> Atomic functions would be used to enforce consistency -- just like a
> thread either fails or succeeds without leaving the mud in an
> inconsistent, half-completed state. Of course, every function
> called at the beginning of a thread is effectively called
> atomically, so code that depends on atomic functions can be replaced
> by code that depends on (atomic) threads. The advantage of atomic
> functions would be to place the function call within the wider
> thread context, which would be similar to imposing an execution
> order on threads. Also, calls to atomic functions could be nested.
Hurm. I'm not entirely sure I understand. Would this be a correct
An atomic function is a member of a special class of functions which
may be called from an executing event, but whose pass/fail result are
reported back to the caller as vs re-entering the C&C mechanism.
Note however that the *ONLY* possible use for such a function is to be
able to call it from an executing event, have it FAIL, and continue
execution of the event despite the failure. Why is this is only
possible use? Because if the function succeeds (the only other
possible return state of a function at this level), then there is no
effective difference between the execution pattern of such an "atomic
function" and any other form. It is only in the FAIL state that the
execution pattern is different.
Delving futher into the FAIL state semantics, if the caller is to also
FAIL because of the atomic function's failure, then the only gain from
the atomic function overhead is is that it may get earlier
notification of its impedending C&C failure via the atomic function
than it would have otherwise. This can be a notable performance
enhancement, but comes at significant cost in complexity of the
execution environment (which is now heirarchial as vs flat) and in
code. Additionally the benefit is only gained for callers of atomic
functions -- all other events suffer the penalty of the more complex
environment without any gain.
It is only when the calling function is intended to continue execution
despite the failure of the atomic function (at the C&C level), that
the execution pattern is different. However the functional gain here
I find (and found, I implemented somethign like this for a while)
to be illusionary. There just is no practical use for the feature.
Note: ColdC has a similar construct with their exception handling
model (Miro or Brandon can probably expand better than I there).
If an event fails C&C, it didn't happen. This seems obvious, but the
ramifications can take a while to sink it. Any event before C&C, or
which has failed C&C has NO existance. It is utterly virtual. What
does this mean? The fact of whether an event failed C&C is
meaningless. The event didn't exist, so therefore its return state
doesn't exist, so there is no semantic content to be found there.
If a tree didn't fall in the woods, did anyone not hear it?
Its a specious question for a more specious topic. You're asking for
the state of a non-existance. If your super-events are supposed to
make process decisions on the return codes of such non-existant
non-entites, just what are they deciding on? That ZZZ should happen
because YYY failed C&C due to Bubba's event C&C'ing first? Its just
J C Lawrence Internet: claw at null.net
(Contractor) Internet: coder at ibm.net
---------(*) Internet: claw at under.engr.sgi.com
...Honourary Member of Clan McFud -- Teamer's Avenging Monolith...
MUD-Dev: Advancing an unrealised future.
More information about the MUD-Dev