Example #1
0
	std::string next_seed_str() {
		uint32_t random_seed_ = next_seed();
		std::stringstream stream;
		stream << std::setfill('0') << std::setw(sizeof(uint32_t)*2) << std::hex << random_seed_;

		return stream.str();
	}
Example #2
0
uint step_pid(uint seed, int nature) {
	int parent_id, secret_id;
	uint pid;
	parent_id = SEED_TO_RAND(seed);
	seed = next_seed(seed);
	secret_id = SEED_TO_RAND(seed);
	seed = next_seed(seed);
	do {
		int pid_row, pid_high;
		pid_row = SEED_TO_RAND(seed);
		seed = next_seed(seed);
		pid_high = SEED_TO_RAND(seed);
		seed = next_seed(seed);
		pid = (uint)pid_high << 16 | (uint)pid_row;
	} while ((int)(pid % 25) != nature);
	return seed;
}
Example #3
0
void sieve(unsigned long i)
{
	unsigned long min = i * (max_num / num_proc) + 1;
	/* If we're on the last thread, set the max equal to the max_prime */
	unsigned long max =(i ==num_proc - 1) ? max_num : min + (max_num / num_proc) - 1;
	unsigned long j;
	unsigned long k;//This is much faster as long as opposed to unsigned int
	j = 1;
	while ((j = next_seed(j)) != 0) {
		for (k = (min / j < 3) ? 3 : (min / j); (j * k) <= max;k++) {
			set_NotPrime(j * k);
		}
	}
}
Example #4
0
void *thread_sort(void *vp){
	unsigned long i = (unsigned long) vp;
	unsigned long min = i * (max_num / num_threads) + 1;
	/* If we're on the last thread, set the max equal to the max_prime */
	unsigned long max =(i == num_threads - 1) ? max_num : min +(max_num / num_threads) - 1;
	unsigned long j;
	unsigned long k;//This is much faster as long as opposed to unsigned int
	j = 1;
	while ((j = next_seed(j)) != 0) {
		for (k = (min / j < 3) ? 3 : (min / j); (j * k) <= max; k++) {
			set_NotPrime(j * k);
		}
	}
	pthread_exit(EXIT_SUCCESS);
}