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
This commit is contained in:
@@ -4,19 +4,21 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* Made into a BeOS /dev/random and /dev/urandom by Daniel Berlin */
|
/* 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 <OS.h>
|
#include <OS.h>
|
||||||
#include <Drivers.h>
|
#include <Drivers.h>
|
||||||
|
|
||||||
|
#include <kernel/thread.h>
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
#define TRACE_DRIVER 0
|
//#define TRACE_DRIVER
|
||||||
#if TRACE_DRIVER
|
#ifdef TRACE_DRIVER
|
||||||
# define TRACE(x) dprintf x
|
# define TRACE(x) dprintf x
|
||||||
#else
|
#else
|
||||||
# define TRACE(x) ;
|
# 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
|
/** The heart of Yarrow 2000 Chuma Random Number Generator: fast and reliable
|
||||||
* randomness collection.
|
* randomness collection.
|
||||||
* Thread yielding function is the most OPTIMAL source of randomness combined
|
* 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.
|
* It doesn't have to switch to another thread, the call itself is random enough.
|
||||||
* Test it yourself.
|
* Test it yourself.
|
||||||
* This FASTEST way to collect minimal randomness on each step couldn't use the
|
* 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 (j = initTimes; j; j--) {
|
||||||
for (i = NK * initTimes; i; i--) {
|
for (i = NK * initTimes; i; i--) {
|
||||||
// Note: there is no yield() in BeOS - we use snooze as an approximation,
|
thread_yield();
|
||||||
// although it might not work as good as this one (especially, it's not
|
|
||||||
// as cheap as).
|
|
||||||
//thread_yield();
|
|
||||||
snooze(5);
|
|
||||||
|
|
||||||
y.Q[0] += system_time();
|
y.Q[0] += system_time();
|
||||||
attach(&x, &y, 0x52437EFFU, 0x026A4CEBU, 0xD9E66AC9U, 0x56E5A975U);
|
attach(&x, &y, 0x52437EFFU, 0x026A4CEBU, 0xD9E66AC9U, 0x56E5A975U);
|
||||||
|
|||||||
Reference in New Issue
Block a user