Extremely poor performance crunching random numbers under PIV-FC5

Jakub Jelinek jakub at redhat.com
Fri May 19 14:20:51 UTC 2006


On Fri, May 19, 2006 at 04:16:40PM +0200, BankHacker wrote:
> Jakub, I have tried to do what you propose but the following code is
> throwing an error in execution time:
> 
> ### prueba-3.c ##################################################
> 	#include <stdio.h>
> 	#include <stdlib.h>
> 	#include <fcntl.h>
> 
> 	int bucle_random_r() {
> 		int nRandom;
> 		struct random_data *randomdataState;

This is an uninitialized pointer:

> 		static int buf[32];
> 		time_t seconds;
> 		extern void *memset (void *__s, int __c, size_t __n) __THROW;

Don't do this ^^^, string.h provides prototype.
> 
> 		memset(randomdataState, 0, sizeof(*randomdataState));

And you dereference the uninitialized pointer here ^^^.

Either have
struct random_data randomdataState;
and replace current uses of *randomdataState with randomdataState and
currnet uses of randomdataState with &randomdataState, or initialize
the pointer to an address of some struct random_data.

	Jakub




More information about the fedora-list mailing list