unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Marius Vollmer <mvo@zagadka.de>
Cc: Mikael Djurfeldt <djurfeldt@nada.kth.se>
Subject: Re: SCM_DEFER_INTS versus error
Date: Thu, 18 Sep 2003 00:58:19 +0200	[thread overview]
Message-ID: <87ekyf9g50.fsf@zagadka.ping.de> (raw)
In-Reply-To: <87el0028c2.fsf@zip.com.au> (Kevin Ryde's message of "Tue, 05 Aug 2003 11:37:17 +1000")

Kevin Ryde <user42@zip.com.au> writes:

> I noticed in the little program below, the thread seems to get hung
> after an error in the mainline has done an SCM_DEFER_INTS in strptime
> then escaped with an error, apparently not doing an SCM_ALLOW_INTS.
>
> Is there a theory on what should happen with this?  Is an error meant
> to re-allow ints or should code be careful to do an ALLOW after any
> DEFER?  The latter no doubt makes sense irrespective of what an error
> throw does.

The whole DEFER/ALLOW business is anachronistic (in my view at least)
and should go away.  Originally, it was used to mark sections of code
that could not tolerate being interrupted, at a time when POSIX
signals could run Scheme code right from the signal handler and that
Scheme code could invoke continuations or throw to a catch.
SCM_DEFER_INTS would, well, defer the execution of signal handlers
until the next ALLOW_INTS.  Originally, it had nothing to do with
threads.

We have a different model for signal delivery now: Scheme signal
handlers are always deferred and are run by SCM_TICK, when it is safe
to do so.

So there no longer is the danger of code being interrupted in a
massive way (of course, C signal handlers still run asynchronously,
but they are careful not to mess things up).

With concurrent threads, we need to protect global data structures,
but I would say that the existing DEFER/ALLOW markup is not the right
tool for this.  Right now (if I'm still uptodate), only one thread can
execute 'in Guile', and thus we need no more explicit protection than
for the old coop threads.

Pragmatically, I don't think we can rely on DEFER/ALLOW to always come
in perfectly balanced pairs and I don't think it is worthwhile to make
sure that they do.  The way DEFER/ALLOW are defined now (as
locking/unlocking a mutex) is subtly different from what they did
previously (setting/clearing a flag in a non-nested way).

I don't think we should keep the current meaning of DEFER/ALLOW.
Instead, we should make them noops and deprecate their usage.  We
should be able to make them noops right now.  Mikael, do you agree?

> Incidentally, I don't think I understand why current-time has a
> SCM_DEFER_INTS.  A simple call to time() ought to be safe shouldn't
> it?

Yes.  Traditionally, all calls to functions outside of libguile were
wrapped in DEFER/ALLOW since we didn't want external functions to be
interrputed by Scheme signal handlers.  It was not to ensure proper
behavior with preemptive threads.

-- 
GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3  331E FAF8 226A D5D4 E405


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel


  reply	other threads:[~2003-09-17 22:58 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-08-05  1:37 SCM_DEFER_INTS versus error Kevin Ryde
2003-09-17 22:58 ` Marius Vollmer [this message]
2003-09-19 20:34   ` Tom Lord
2003-09-22 18:01     ` Marius Vollmer
2003-09-20 23:44   ` Kevin Ryde
2003-09-22 18:10     ` Marius Vollmer
2003-09-23  1:01       ` Mikael Djurfeldt
2003-10-07 17:54         ` Marius Vollmer
2003-12-06 21:15       ` Kevin Ryde

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ekyf9g50.fsf@zagadka.ping.de \
    --to=mvo@zagadka.de \
    --cc=djurfeldt@nada.kth.se \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).