Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Please sonar about unsecure usage of rand().
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Sat, 2 Oct 2021 11:57:20 +0000 (13:57 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Sat, 2 Oct 2021 18:54:25 +0000 (20:54 +0200)
sg_actor_self_get_pid() makes a perfect random number here.

Remember https://xkcd.com/221/

teshsuite/smpi/coll-allgather/coll-allgather.c

index a6955de..7134a58 100644 (file)
@@ -17,8 +17,7 @@ int main(int argc, char *argv[])
   int size;
   int status;
 
-  srand(sg_actor_self_get_pid());
-  int randomTime = rand() %5;
+  int randomTime = sg_actor_self_get_pid() % 5;
   sleep(randomTime);
 
   MPI_Init(&argc, &argv);