Книга: Programming with POSIX® Threads

6.5.5 Random number generation

6.5.5 Random number generation

int rand_r (unsigned int *seed);

The seed is maintained in caller-supplied storage (seed) rather than using static storage internal to the function. The main problem with this interface is that it is not usually practical to have a single seed shared by all application and library code within a program. As a result, the application and each library will generally have a separate "stream" of random numbers. Thus, a program converted to use rand_r instead of rand is likely to generate different results, even if no threads are created. (Creating threads would probably change the order of calls to rand, and therefore change results anyway.)

Оглавление книги


Генерация: 1.682. Запросов К БД/Cache: 3 / 0
поделиться
Вверх Вниз