[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: scm_i_fraction_reduce thread safety
From: |
Kevin Ryde |
Subject: |
Re: scm_i_fraction_reduce thread safety |
Date: |
Thu, 15 Jan 2004 07:09:17 +1000 |
User-agent: |
Gnus/5.110002 (No Gnus v0.2) Emacs/21.3 (gnu/linux) |
Richard Todd <address@hidden> 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).
- Re: scm_i_fraction_reduce thread safety, Marius Vollmer, 2004/01/10
- Re: scm_i_fraction_reduce thread safety, Kevin Ryde, 2004/01/10
- Re: scm_i_fraction_reduce thread safety, Marius Vollmer, 2004/01/10
- Re: scm_i_fraction_reduce thread safety, Marius Vollmer, 2004/01/20
- Re: scm_i_fraction_reduce thread safety, Carl Witty, 2004/01/20
- Re: scm_i_fraction_reduce thread safety, Marius Vollmer, 2004/01/21
- Re: scm_i_fraction_reduce thread safety, Dirk Herrmann, 2004/01/27
- Re: scm_i_fraction_reduce thread safety, Rob Browning, 2004/01/27
- Re: scm_i_fraction_reduce thread safety, Marius Vollmer, 2004/01/29
- Re: scm_i_fraction_reduce thread safety, Rob Browning, 2004/01/29
- Re: scm_i_fraction_reduce thread safety, Mikael Djurfeldt, 2004/01/30