Subject: Re: kernel ip_randomid() and libc randomid(3) still "broken"
To: None <simonb@wasabisystems.com>
From: Jun-ichiro itojun Hagino <itojun@itojun.org>
List: tech-net
Date: 11/26/2003 07:11:47
> Even with this code, the gap still settles down to just under 12000 and
> not the 36000 advertised in the manpage. src/regress/lib/libc/randomid
> still fails because of this. See this following bit of code:
>
> > X /* Skip a random number of ids */
> > X n = tmp & 0x3; tmp = tmp >> 2;
> > X if (ru_counter + n >= RU_MAX)
> > X ip_initid();
> > X
> > X for (i = 0; i <= n; i++)
> > X /* Linear Congruential Generator */
> > X ru_x = (ru_a * ru_x + ru_b) % RU_M;
>
> While we throw away up to 3 random numbers each time we ask for a single
> random number, we're always going to have a minimum gap of approximately
> 1/3rd the theoretical gap.
the "skipping" part is not documented in the source code comment,
therefore i made mistake while i'm writing up manpage.
so we can either:
- stop skipping random number of ids (n=0)
- reduce numbers on the manpage to 1/3
and then we are happpy.
itojun