Subject: suspend() thougths

From: [email-masked]
Date: Sat, 18 Sep 1993 08:21:42 -0700

suspend() leads to things like :suspend_if_needed() on Lambda. 
:suspend_if_needed() is bad, bass-ackwards, etc.  Perhaps the following
modification to MOO would make things better:

Add a bit to each verb called the 'a' bit (for "atomic").  Verbs with their
'a' bit set are assumed to require that no suspend() calls take place anywhere
in their code or verbs they call (to ensure proper settings for properties on
objects before other tasks are engaged, etc.).  In short, they act pretty much
like all verbs do now.  The new semantics are that when an 'a' verb calls a
'!a' verb, an error occurs.  Also, when suspend is called with an 'a' verb on 
the stack, an error occurs.  The fact that these things generate errors would 
help in some cases tracking down suspend calls when they might screw things up.

Verbs which are '!a' simply get suspended if and when they require it, for
running out of ticks or seconds.  They would be semanticly equivalent to
putting :suspend_if_needed()s all over the place.  As to how many seconds this
auto-suspend should be for, I'm sure we can all agree upon something like
FIVE.

I'm hesitant to try to implement this for fear of getting tied up in it for a
long time, but the MOO source is so notoriously nice I'm game.  What do you
folks think?

--joe
-K*

---

From: [email-masked] (H. Peter Anvin N9ITP)
Date: Sat, 18 Sep 1993 11:34:33 -0700

[email-masked] proposes:

a  = must not suspend
!a = may not suspend, auto-suspended when necessary

There is a problem here.  Some verbs may want to suspend at designated
points only.  There would either have to be a critical..endcritical
construct in the MOO language, or there would have to be an in-between
between the two alternatives.  For example, with two flags:

s  = may suspend by explicit suspend()
!s = must not call suspend()
a  = can be auto-suspended
!a = must not be auto-suspended

Restrictions:

!s verbs must not call s or a verbs.
!a verbs must not call a verbs.

The autosuspend delay should be a compile-time option, left up to the
archwizard.

	/hpa

--   
INTERNET: [email-masked]         FINGER/TALK: [email-masked]
IBM MAIL: I036073 at IBMMAIL  NeXTMAIL:    [email-masked]
ANMDRKNING: Heja Sverige friskt humvr!  EG vdntar utanfvr!
WNT: Just one step behind VMS

---

From: [email-masked]
Date: Sun, 19 Sep 1993 19:01:11 -0700

> between the two alternatives.  For example [ delted ]

Adding critical section constructs to the MOO language would theoretically
allow the MOO program to back out a sequence of property modifications in the
case of running out of ticks or seconds in a critical section -- I see this
as pounding tacks into cork with a sledgehammer.

With an 'a' bit you could just stick the part of your verb that needed atomic
update in a separate verb.  For example:

@program foo which is '!a'
this:duh();
this:_critical_section(4);
this:duh();
.

@program _critical_section which is 'a'
this.same1 = args[1];
this.same2 = args[2];
this.same3 = args[3];
.

The verb foo would be able to call duh() which would be automaticly suspended
(if needed) and still make sure the .same properties on it were all the same
thing.  The paranoid may even put a suspend() in before the call to
_critical_section() just for luck.

--joe

---

From: [email-masked]
Date: Sun, 19 Sep 1993 19:44:51 -0700

> between the two alternatives.  For example [ delted ]

Um, well, um, well, um.  OK, I get it now.  Forget I said anything because it
turns out that unless we do something EVIL with two bits like H. Peter Anvin
suggested much existing code will break -- namely any that does suspend() on
purpose in a specific spot.

Sorry to have riddled your mbox with what turns out to be a bad idea.

--joe