To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcx.legosOpen lugnet.robotics.rcx.legos in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / legOS / 599
598  |  600
Subject: 
Re: random() compile problems
Newsgroups: 
lugnet.robotics.rcx.legos
Date: 
Tue, 21 Dec 1999 11:59:10 GMT
Viewed: 
1649 times
  
Martin Cornelius wrote:
Hi Matthew, it lokks like the functions are simply not defined neither
in the legOS kernel nor in the libs. Following the comment in
include/stdlib.h, they should be in libiberty.a, which is somewhere in
the cross-compiler tree. However, searching through the librarys found

Yes, it looks like random is in a private library of mine, sorry. With
all the exciting networking development happening, count on 0.2.4 being
released soon, it will contain random() again.

there with nm, i found nothing like random. i´d bet, Markus has an
enhanced libiberty that has it. BTW, the legOS kernel itself uses
sys_time to provide some randomness, look at the very end of
lnp_logical_write(), where a random value is needed when computing
allow_tx after a collision.

For small amounts of random numbers, you may consider using a generator
like this:

#define PRIME1  402653189
#define PRIME2  201326611

static unsigned long random_pool;

void random_init() {
random_pool=sys_time;
}

unsigned long random() {
unsigned long random_value=PRIME1*random_pool;
random_pool=PRIME2*(random_pool+sys_time);
return random_value;
}

where PRIME1 and PRIME2 are suitably large prime numbers (for looks.
Actually, large odd numbers suffice).

Note this doesn't generate a repeatable sequence of random numbers,
because sys_time is used in random(), too.

Markus.

--
"Nieder mit den Zitaten!" -Markus L. Noga <markus@noga.de>



Message is in Reply To:
  Re: random() compile problems
 
(...) Hi Matthew, it lokks like the functions are simply not defined neither in the legOS kernel nor in the libs. Following the comment in include/stdlib.h, they should be in libiberty.a, which is somewhere in the cross-compiler tree. However, (...) (25 years ago, 21-Dec-99, to lugnet.robotics.rcx.legos)

3 Messages in This Thread:

Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR