Re: Extremely poor performance crunching random numbers under PIV-FC5

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Filling szBufferState with random data is completely unnecessary,
initstate_r overwrites it anyway.
If you want to initialize randomdataState the same way srandom(seconds);
does, don't open /dev/urandom at all and just do:
static int buf[32];
memset (randomdataState, 0, sizeof (*randomdataState));
initstate_r (seconds, (char *) buf, 128, &randomdataState);

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;
		static int buf[32];
		time_t seconds;
		extern void *memset (void *__s, int __c, size_t __n) __THROW;

		memset(randomdataState, 0, sizeof(*randomdataState));
		initstate_r(seconds, (char *) buf, 128, randomdataState);

		random_r(randomdataState, &nRandom);
		printf("%d\n", nRandom);

		return 1;
	}


	int main(int argc, char ** argv) {
		bucle_random_r();
		return (0);
	}
#################################################################

This is the result:
	# gcc prueba-3.c -o 3prueba -Wall -pedantic -O0

	#./3prueba
	Segmentation fault

The "Segmentation fault" occurs when executing memset instruction. I
don't know why ...

--
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux