From ecc6684dcaa27ec7328701cfe7a9975a92f14e1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Sun, 5 Mar 2006 20:06:44 +0000 Subject: [PATCH] Now uses thread_yield() instead of snooze(5), patch by Danny Robson. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16589 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/add-ons/kernel/drivers/random/driver.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/add-ons/kernel/drivers/random/driver.c b/src/add-ons/kernel/drivers/random/driver.c index 6ace57275c..f60b6dd859 100644 --- a/src/add-ons/kernel/drivers/random/driver.c +++ b/src/add-ons/kernel/drivers/random/driver.c @@ -4,19 +4,21 @@ */ /* Made into a BeOS /dev/random and /dev/urandom by Daniel Berlin */ -/* Adapted for Haiku by David Reid, Axel Doerfler */ +/* Adapted for Haiku by David Reid, Axel Dörfler */ #include #include +#include + #include #include #include -#define TRACE_DRIVER 0 -#if TRACE_DRIVER +//#define TRACE_DRIVER +#ifdef TRACE_DRIVER # define TRACE(x) dprintf x #else # define TRACE(x) ; @@ -169,7 +171,7 @@ chseed(ch_randgen *prandgen, const uint64 seed) /** The heart of Yarrow 2000 Chuma Random Number Generator: fast and reliable * randomness collection. * Thread yielding function is the most OPTIMAL source of randomness combined - * with a clock counter (editor's note: thread_yield() is not properly done in BeOS). + * with a clock counter. * It doesn't have to switch to another thread, the call itself is random enough. * Test it yourself. * This FASTEST way to collect minimal randomness on each step couldn't use the @@ -189,11 +191,7 @@ reseed(ch_randgen *prandgen, const uint32 initTimes) for (j = initTimes; j; j--) { for (i = NK * initTimes; i; i--) { - // Note: there is no yield() in BeOS - we use snooze as an approximation, - // although it might not work as good as this one (especially, it's not - // as cheap as). - //thread_yield(); - snooze(5); + thread_yield(); y.Q[0] += system_time(); attach(&x, &y, 0x52437EFFU, 0x026A4CEBU, 0xD9E66AC9U, 0x56E5A975U);