Re: create_proc_info_entry

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

 



On Fri, 2007-06-01 at 11:27 -0500, Greg Donald wrote:
> On 5/31/07, Avishay Traeger <atraeger@xxxxxxxxxxxxx> wrote:
> > You can only use "exported" functions from modules.  Functions are
> > exported from the kernel using "EXPORT_SYMBOL(function_name);"
> > For random numbers, maybe take a look at srandom32() to set the random
> > seed and random32() to get a random 32-bit number.
> 
> Thanks, that works fine.
> 
> Do I _need_ to call srandom32() before using random32()?  Calling
> rmmod and insmod a few times, it appears to be seeded already.
> 
> Assuming I need to call it, what can I use to seed it?  I don't have
> time() from time.h anymore so this doesn't work:
> 
> srandom32( ( unsigned ) time( NULL ) / 2 );

I don't know if you NEED to call srandom32(), but it surely can't hurt.
Instead of time(), by which I assume you mean the system call that you
might use from user-space, you can try using:
- the lower 32 bits of "jiffies" (include/linux/jiffies.h)
- do_gettimeofday() and use the microsecond counter (make sure to only
use 32 bits).

Avishay


--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux