From a2ca07f4ec068a6db32b3e0dac7227e9aeae0eb0 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Wed, 12 Mar 2008 20:36:19 +0000 Subject: [PATCH] The random driver story isn't over yet, it seems. The many thread_yield() calls make reseed() really slow in a busy system, since another thread will exhausts its full quantum between two thread_yield() calls. And 257 * 8 * 8 quanta are about 49s. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24375 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/add-ons/kernel/drivers/random/driver.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/add-ons/kernel/drivers/random/driver.c b/src/add-ons/kernel/drivers/random/driver.c index 495b716603..55fa7a9909 100644 --- a/src/add-ons/kernel/drivers/random/driver.c +++ b/src/add-ons/kernel/drivers/random/driver.c @@ -191,8 +191,17 @@ reseed(ch_randgen *prandgen, const uint32 initTimes) for (j = initTimes; j; j--) { for (i = NK * initTimes; i; i--) { + // TODO: Yielding sounds all nice in principle, but this will take + // ages (at least initTimes * initTimes * NK * quantum, i.e. ca. 49s + // for initTimes == 8) in a busy system. Since perl initializes its + // random seed on startup by reading from /dev/urandom, perl + // programs are all but unusable when at least one other thread + // hogs the CPU. thread_yield(false); + // TODO: Introduce a clock_counter() function that directly returns + // the value of the hardware clock counter. This will be cheaper + // and will yield more randomness. y.Q[0] += system_time(); attach(&x, &y, 0x52437EFFU, 0x026A4CEBU, 0xD9E66AC9U, 0x56E5A975U); attach(&y, &x, 0xC70B8B41U, 0x9126B036U, 0x36CC6FDBU, 0x31D477F7U);