Hi all,
Can someone please tell me where can I find and which random/pseudo-random number generator can I use inside the linux kernel? (2.4.28)
I found out 1 function get_random_bytes() in linux/drivers/char/random.c but thats not what I want.
I want a function where I will be supplying a seed to that function as an input, and will get a random number back. If same seed is used, same number should be generated again.
Can anybody please help me with that?
Thanks and regards,
Vineet.
_______________________________________________
Join Excite! - http://www.excite.com
The most personalized portal on the Web!
As far as I understand the kernel generates random numbers gathering
data from several entropy sources, you will never get repetability
from there. Two options I know of:
1) The standard C library has the functions rand and random, wich
seems to have a decent distribution of the random numbers.
2) If you use C++, the Boost library (http://www.boost.org) has an excelent
set of options for generating random numbers.
Dar?o
On Mon, 7 Mar 2005 18:18:53 -0500 (EST), Vineet Joglekar
<[email protected]> wrote:
>
> Hi all,
>
> Can someone please tell me where can I find and which random/pseudo-random number generator can I use inside the linux kernel? (2.4.28)
>
> I found out 1 function get_random_bytes() in linux/drivers/char/random.c but thats not what I want.
>
> I want a function where I will be supplying a seed to that function as an input, and will get a random number back. If same seed is used, same number should be generated again.
>
> Can anybody please help me with that?
>
> Thanks and regards,
>
> Vineet.
>
> _______________________________________________
> Join Excite! - http://www.excite.com
> The most personalized portal on the Web!
> -
> To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
--
That is not dead which can eternal lie,
and with strange aeons, even death may die.
On Mon, Mar 07, 2005 at 06:18:53PM -0500, Vineet Joglekar wrote:
> I want a function where I will be supplying a seed to that function
> as an input, and will get a random number back. If same seed is used,
> same number should be generated again.
Google for "Numerical recipes in C", it has a complete section about
random numbers, including a couple of functions that do what you want.
Erik
--
+-- Erik Mouw -- http://www.harddisk-recovery.com -- +31 70 370 12 90 --
| Lab address: Delftechpark 26, 2628 XH, Delft, The Netherlands
I think ur idea of generating a random number
with a seed will not be effective. The kernel comes up
with true random number generation by using the random
interaction of device drivers with the kernel. I think
that will be more effective than ur logic. It provides
true randomness and it avoids any guess.
For more details u please refer the book ' Linux
kernel development' by Robert M Love Appendix C kernel
Random Number Generator. If u still want to stick to
ur own logic then u can implement it as a function
inside the kernel.
Regards,
selva
--- Vineet Joglekar <[email protected]> wrote:
>
> Hi all,
>
> Can someone please tell me where can I find and
> which random/pseudo-random number generator can I
> use inside the linux kernel? (2.4.28)
>
> I found out 1 function get_random_bytes() in
> linux/drivers/char/random.c but thats not what I
> want.
>
> I want a function where I will be supplying a seed
> to that function as an input, and will get a random
> number back. If same seed is used, same number
> should be generated again.
>
> Can anybody please help me with that?
>
> Thanks and regards,
>
> Vineet.
>
> _______________________________________________
> Join Excite! - http://www.excite.com
> The most personalized portal on the Web!
> -
> To unsubscribe from this list: send the line
> "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at
> http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
__________________________________
Celebrate Yahoo!'s 10th Birthday!
Yahoo! Netrospective: 100 Moments of the Web
http://birthday.yahoo.com/netrospective/
Vineet Joglekar wrote:
> Hi all,
>
> Can someone please tell me where can I find and which
> random/pseudo-random number generator can I use inside the linux
> kernel? (2.4.28)
>
> I found out 1 function get_random_bytes() in
> linux/drivers/char/random.c but thats not what I want.
>
> I want a function where I will be supplying a seed to that function
> as an input, and will get a random number back. If same seed is used,
> same number should be generated again.
Without knowing what you're doing I can't say if it justifies having all
that extra code around, but the stuff from the library, like srand48,
will do this. You can add the code to your module.
--
-bill davidsen ([email protected])
"The secret to procrastination is to put things off until the
last possible moment - but no longer" -me