From: Kevin Ryde <user42@zip.com.au>
Subject: Re: scm_i_fraction_reduce thread safety
Date: Thu, 15 Jan 2004 07:09:17 +1000 [thread overview]
Message-ID: <87eku25jb6.fsf@zip.com.au> (raw)
In-Reply-To: <40022F15.30903@vzavenue.net> (Richard Todd's message of "Sun, 11 Jan 2004 23:22:29 -0600")
Richard Todd <richardt@vzavenue.net> writes:
>
> 1) If you are worried about thread safety, the most fool-proof C
> interface probably does not allow separate access to numerator and
> denominator, since they need to be read in one atomic operation to
> ensure consistent results in the face of other mutating code.
Or don't mutate, except possibly under gc.
> 2) Aren't (numerator frac) and (denominator frac) themselves other
> examples of would-be readers that might have to 'write back' in this
> setup?
Yep.
> For the speed issue in general, doesn't it come down to whether the
> extra gcd()s of eager reduction would be cheaper than the
> mutex_lock()s of lazy reduction?
Well, locks will slow down accesses, but the question of when to do
gcds really depends on num+den at risk of growing more or less
unboundedly and on the way gcd is O(N^2) so much better to do on
smaller operands where possible (assuming a reduction will in fact be
wanted at some point, which would not be the case say if rounding to
an int or float at the end).
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel
next prev parent reply other threads:[~2004-01-14 21:09 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-12-11 11:43 scm_i_fraction_reduce thread safety Bill Schottstaedt
2003-12-11 19:19 ` Carl Witty
2003-12-12 12:11 ` Bill Schottstaedt
2003-12-12 15:04 ` Paul Jarc
2003-12-12 23:23 ` Kevin Ryde
2004-01-10 22:38 ` Marius Vollmer
2004-01-10 23:29 ` Kevin Ryde
2004-01-11 1:31 ` Marius Vollmer
2004-01-12 0:51 ` Kevin Ryde
2004-01-12 5:22 ` Richard Todd
2004-01-14 21:09 ` Kevin Ryde [this message]
2004-01-21 0:03 ` Marius Vollmer
2004-01-21 0:00 ` Marius Vollmer
2004-01-21 3:11 ` Carl Witty
2004-01-21 21:06 ` Marius Vollmer
2004-01-27 22:15 ` Dirk Herrmann
2004-01-27 23:24 ` Rob Browning
2004-01-29 19:35 ` Marius Vollmer
2004-01-29 20:32 ` Rob Browning
2004-01-30 14:45 ` Mikael Djurfeldt
2004-02-01 18:49 ` Andy Wingo
-- strict thread matches above, loose matches on Subject: below --
2003-12-09 20:39 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=87eku25jb6.fsf@zip.com.au \
--to=user42@zip.com.au \
/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).