Visit Jeremy's Blog.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 12-24-2005, 05:44 PM   #1
Registered: Jul 2005
Posts: 33

Rep: Reputation: 15
Random number generator inside kernel space

Hello all, I'm trying to implement a kernel module and I need a random number generator. Since this is a kernel module, standard functions like rand() will not work, so anybody knows what I should do in order to obtain random or pseudo random number generators? Thanks in advance
Old 12-24-2005, 06:45 PM   #2
LQ Guru
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Actually, the kernel happens to implement a random number generator, accessible from /dev/random or /dev/urandom, or get_random_bytes().

See "Linux Kernel Development, 2nd Ed", Robert Love, Appendix B for more details.
Old 12-26-2005, 04:02 PM   #3
Senior Member
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
AFAIK, the .ko modules in 2.6 are linked from .o files (unlike 2.4 modules.) To compile those you generally feed off of the kernel makefile, but I'm sure you could find a way to link in standard libs (statically if nothing else.) I agree with paulsm4, though; /dev/urandom is the best way to go for random.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
does GNU's g77 come with a random number generator? terrence Programming 1 08-30-2005 09:29 PM
Number series generator sniff Programming 8 08-23-2005 03:26 AM
Help: Need random password generator linuxgamer Linux - Software 5 12-02-2003 01:01 PM
I need random number in C ... purpleburple Programming 4 10-28-2002 04:37 AM
Random number generator for linux Steve_Taylor Programming 12 09-30-2001 04:21 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:05 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration