Hi! Don't use random.h's `random()` in GNU Radio. It's not thread-safe and mustn't be used in multithreaded applications, and GNU Radio is inherently multithreaded.
> So I tried to use srand(time(0)) That is **explicitly** a way to get a different sequence every time, so this is very counter-productive. Have you read `srand`'s and `time`'s manual pages at all? Since you're probably using a C++ compiler that has C++11 support, simply use #include <random> // NOT random.h int main() { int seed = 42; // constant that defines the sequence we're getting std::mt19937 rng(seed); //default mersenne_twister_engine std::uniform_real_distribution<> uni(0.0, 1.0); for (int n = 0; n < 10; ++n) { double uniform_number = uni(rng); } } Best regards, Marcus #On Thu, 2018-05-24 at 18:17 +0900, 김무연 wrote: > Hi all! > Could I ask something? > I want to generate random numbers > So when I make a block, I included random.h and I used random() function > But every time it produces the same output > And I want to use this blocks twice in the gnuradio > So I tried to use srand(time(0)) > But it didn't work > My question is this are there any method to do the same role of > srand(time(0)) when I create a block in gnuradio? > Thanks > > _______________________________________________ > Discuss-gnuradio mailing list > Discuss-gnuradio@gnu.org > https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ Discuss-gnuradio mailing list Discuss-gnuradio@gnu.org https://lists.gnu.org/mailman/listinfo/discuss-gnuradio