Re: [rtl] generating random numbers

2000-08-11 Thread Wilken Boie


Adi Sudewa schrieb:
> 
> Hi all,
> 
> how to generate random integers from within real-time thread.
> I need to generate random numbers so my simulation can be unpredictable.
> It is not cool to have a train running with 20.00 m/s speed
> all the time so I'd like to have the speed fluctuate round 20.00 m/s.
> 
Here is an extremely simple one (from 
http://www.realtimelinux.org/CRAN/src/rtUtils-v0.1.0.h)

static unsigned long rtseed = 0;
unsigned long rtrand( void ) {
  rtseed = rtseed * 0x41C64E6D + 0x3039;
  return (rtseed>>16)&0x7FFF;
}

Have fun
Wilken
-- [rtl] ---
To unsubscribe:
echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
echo "unsubscribe rtl " | mail [EMAIL PROTECTED]
---
For more information on Real-Time Linux see:
http://www.rtlinux.org/rtlinux/




RE: [rtl] generating random numbers (rtl-digest V1 #94)

2000-08-11 Thread KULECZ, WALTER (JSC-SD)

> --
> 
> Date: Wed, 9 Aug 2000 00:55:40 -0700
> From: David Schleef <[EMAIL PROTECTED]>
> Subject: Re: [rtl] generating random numbers
> 
> On Wed, Aug 09, 2000 at 12:58:20PM +0700, Adi Sudewa wrote:
> > 
> > Hi all,
> > 
> > how to generate random integers from within real-time thread.
> > I need to generate random numbers so my simulation can be 
> unpredictable.
> > It is not cool to have a train running with 20.00 m/s speed 
> > all the time so I'd like to have the speed fluctuate round 
> 20.00 m/s.
> 
> 
> The GNU Scientific Library has one of the finest collections
> of PRNGs, from the trivially simple to ones capable of real
> work, and then some capable of Real Work (tm).  I'd pick a
> relatively simple one and port it to RT.

Unless there is a compelling reason to have this in the real time task, I'd
calculate the random numbers in a user program and write them to the
real-time task via a rtl FIFO.

I've sent two channels of D/A data at 240 Hz with some really lame hardware
(DT2801) using this method.  Its clean, versatile and works well.

You can get "real" random numbers by hooking a white noise generator to the
sound card (or A/D if you have one) and reading it.

--wally.
-- [rtl] ---
To unsubscribe:
echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
echo "unsubscribe rtl " | mail [EMAIL PROTECTED]
---
For more information on Real-Time Linux see:
http://www.rtlinux.org/rtlinux/




Re: [rtl] generating random numbers

2000-08-10 Thread Tomasz Motylewski

On Thu, 10 Aug 2000, Adi Sudewa wrote:

> > You could used get_random_bytes().  See linux/random.h for the
> > prototype.
> 
> I already try it. But when I insmod random.o, I get this message :
> ``couldn't find the kernel version the module was compiled for''.

Because it is not a module. That code is always compiled in the kernel - TCP
uses it. Just use it.

To get your numbers more random you might wish to feed more noise into
"enthropy pool" - use every hard disk and network interrupt to add the noise
- look (grep kernel source) for places where

 *  void add_interrupt_randomness(int irq);
 *  void add_blkdev_randomness(int irq);

are used and see how to activate it. 

Best regards,
--
Tomek

-- [rtl] ---
To unsubscribe:
echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
echo "unsubscribe rtl " | mail [EMAIL PROTECTED]
---
For more information on Real-Time Linux see:
http://www.rtlinux.org/rtlinux/




Re: [rtl] generating random numbers

2000-08-10 Thread Adi Sudewa

On Thu, 10 Aug 2000, Nathan Simons wrote:
>   You could used get_random_bytes().  See linux/random.h for the
> prototype.

I already try it. But when I insmod random.o, I get this message :
``couldn't find the kernel version the module was compiled for''.

Actually, it is a very good random number generator, but what I need is
just a simple algorithm. I can't get to world wide web right now 
(the 3rd world internet infrastructure suck :(, connection is too slow
and only paying students are given access), 
so please someone send one algorithm that I can use ?
I will highly appreciate it.

(It's summer vacation, so my friends who once taking simulation and
modeling class is not here :()

TIA,
-dewa-

-- [rtl] ---
To unsubscribe:
echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
echo "unsubscribe rtl " | mail [EMAIL PROTECTED]
---
For more information on Real-Time Linux see:
http://www.rtlinux.org/rtlinux/




Re: [rtl] generating random numbers

2000-08-09 Thread Nathan Simons

On Wed, Aug 09, 2000 at 12:58:20PM +0700, Adi Sudewa wrote:
> how to generate random integers from within real-time thread.
> I need to generate random numbers so my simulation can be unpredictable.
> It is not cool to have a train running with 20.00 m/s speed 
> all the time so I'd like to have the speed fluctuate round 20.00 m/s.

You could used get_random_bytes().  See linux/random.h for the
prototype.

-- 
Nathan Paul Simons, Programmer for FSMLabs
http://www.fsmlabs.com/
-- [rtl] ---
To unsubscribe:
echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
echo "unsubscribe rtl " | mail [EMAIL PROTECTED]
---
For more information on Real-Time Linux see:
http://www.rtlinux.org/rtlinux/




Re: [rtl] generating random numbers

2000-08-09 Thread David Schleef

On Wed, Aug 09, 2000 at 12:58:20PM +0700, Adi Sudewa wrote:
> 
> Hi all,
> 
> how to generate random integers from within real-time thread.
> I need to generate random numbers so my simulation can be unpredictable.
> It is not cool to have a train running with 20.00 m/s speed 
> all the time so I'd like to have the speed fluctuate round 20.00 m/s.


The GNU Scientific Library has one of the finest collections
of PRNGs, from the trvially simple to ones capable of real
work, and then some capable of Real Work (tm).  I'd pick a
relatively simple one and port it to RT.




dave...

-- [rtl] ---
To unsubscribe:
echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
echo "unsubscribe rtl " | mail [EMAIL PROTECTED]
---
For more information on Real-Time Linux see:
http://www.rtlinux.org/rtlinux/




[rtl] generating random numbers

2000-08-08 Thread Adi Sudewa


Hi all,

how to generate random integers from within real-time thread.
I need to generate random numbers so my simulation can be unpredictable.
It is not cool to have a train running with 20.00 m/s speed 
all the time so I'd like to have the speed fluctuate round 20.00 m/s.

TIA
dewa


-- [rtl] ---
To unsubscribe:
echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
echo "unsubscribe rtl " | mail [EMAIL PROTECTED]
---
For more information on Real-Time Linux see:
http://www.rtlinux.org/rtlinux/