unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Mikael Djurfeldt <mdj@mit.edu>
Cc: djurfeldt@nada.kth.se
Subject: Re: pthread fast mutexes
Date: Mon, 23 Feb 2004 17:05:16 -0500	[thread overview]
Message-ID: <xy73c91e9k3.fsf@chunk.mit.edu> (raw)
In-Reply-To: <87ishxv6m5.fsf@zip.com.au> (Kevin Ryde's message of "Tue, 24 Feb 2004 07:16:50 +1000")

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

> In the current cvs on my i386 debian,
>
> 	(unlock-mutex (make-mutex))
>
> gives a seg fault.
>
> I'm guessing it's because make-mutex uses a pthread fast mutex, and
> that style means no error checking by the unlock.
>
> Maybe the scheme level functions will need to use the "normal" mutexes
> so the above can throw an exception.  Or is there some other theory on
> this?

The "theory" is this:

The idea of the current thread interface design is to be able to "plug
in" a thread library.  It's therefore good if we keep the demands on
the thread library to a minimum.  Not all thread libraries supports
detection of this kind of error.  Therefore I opted for leaving it
undefined what happens if you try to unlock an unlocked mutex.

Here's an excerpt of the docs for pthread_mutex_unlock:

  pthread_mutex_unlock unlocks the given mutex. The mutex is assumed to
  be locked and owned by the calling thread on entrance to
  pthread_mutex_unlock.  If the mutex is of the ``fast'' kind,
  pthread_mutex_unlock always returns it to the unlocked state.

Therefore, fast mutexes are consistent with the requirements of the
interface, and they are, well, fast...  The call above doesn't
generate a segfault on my system.

BUT, obviously, if these docs don't hold for the fast mutexes on other
systems, then we can't use them on those systems.  How is
pthread_mutex_unlock for a fast mutyex documented on your system?

Also, my design choices above could be discussed.

M


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


  reply	other threads:[~2004-02-23 22:05 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-23 21:16 pthread fast mutexes Kevin Ryde
2004-02-23 22:05 ` Mikael Djurfeldt [this message]
2004-02-23 22:22   ` Mikael Djurfeldt
2004-02-23 23:46     ` Kevin Ryde
2004-02-24  0:02       ` Mikael Djurfeldt
2004-02-28 20:18         ` Kevin Ryde
2004-03-20 22:51     ` Marius Vollmer
2004-02-23 22:33   ` Kevin Ryde
2004-02-24  1:17     ` Mikael Djurfeldt
2004-03-20 22:51       ` Marius Vollmer

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=xy73c91e9k3.fsf@chunk.mit.edu \
    --to=mdj@mit.edu \
    --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).