On Wed, Sep 7, 2022 at 4:55 PM Marc Nieper-Wißkirchen <[email protected]>
wrote:

A Scheme interpreter can be written in a way so that terminating the thread
> does not leave the REPL and the rest of the system in an inconsistent
> state.  This is at least the case with existing Scheme implementations, I
> think.
>

What if one end of a go-channel is open in the thread and the other end in
the REPL?  This is a perfectly reasonable REPL feature to have when
debugging goroutines.

That makes me think that `eval` ought to set an initial continuation frame.

If the time structure is still crucial even after the forced termination of
> any thread, the protocol could be as follows:  The time structure comes
> with a shadow field and an atomic flag.  The mutex is locked when it is
> updated by a thread.  Then the shadow field is populated with the updated
> current time.  Afterward, the atomic flag is raised.  Then the time is
> copied from the shadow field.  Finally, the atomic flag is lowered and the
> mutex is unlocked.
>

(The complexity of this protocol is a fine reason why programs that need a
clock like this should read the value from a channel.)

Marc (in CC) surely can say much more about this, but I thought that the
> idea of abandoned mutexes in SRFI 18 is there so that `terminate-thread!`
> can be handled gracefully.
>

Perhaps so.  I'll wait to hear from him.

Reply via email to