[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-gsl] Random number generators and Pthreads

From: Joseph Wakeling
Subject: [Help-gsl] Random number generators and Pthreads
Date: Mon, 06 Nov 2006 17:14:29 +0100
User-agent: Thunderbird (X11/20060918)

Hello all,

I'm curious about the random number generators and how they can be
effectively used in different situations.  I'm not particularly
experienced with large-scale or parallel programming, so bear with me if
what follows seems stupid.

My "typical" mode of use for the rng would be to create a module in my
program such as,

        /*** myProg_rng.c ********************************/

        #include <gsl/gsl_rng.h>

        gsl_rng *myProg_rng;

        /*** end of myProg_rng.c *************************/

        /*** myProg_rng.h ********************************/

        #include <gsl/gsl_rng.h>

        extern gsl_rng *myProg_rng;

        /*** end of myProg_rng.h *************************/

... which would store the rng to be used by any other part of my code.
Is this a sensible way to proceed or should I actually pass the rng
around between different functions?  Could anyone comment on "good
practice" in using the rng?

The second question is, what if I want to use Pthreads or something
similar (which I'm just trying to teach myself)---do I have to do
anything to restrict access to the rng?  The GSL documentation claims
that gsl is "thread-safe", but I don't know really what this means,
whether GSL will sort everything out with respect to different threads'
access of the rng, or whether I do have to take my own precautions.

Can anyone advise?

Thanks in advance for any comments,

    -- Joe

reply via email to

[Prev in Thread] Current Thread [Next in Thread]