Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright lines with new year.
[simgrid.git] / examples / smpi / mc / mutual_exclusion.c
index 35f7b82..5481c91 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014. The SimGrid Team.
+/* Copyright (c) 2014-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -7,6 +7,7 @@
 #include <stdio.h>
 #include <mpi.h>
 #include <simgrid/modelchecker.h>
+#include <xbt/dynar.h>
 
 #define GRANT_TAG 0
 #define REQUEST_TAG 1
@@ -17,7 +18,6 @@ int main(int argc, char **argv){
   int rank;
   int recv_buff;
   MPI_Status status;
-  int CS_used = 0;
   xbt_dynar_t requests = xbt_dynar_new(sizeof(int), NULL);
 
   /* Initialize MPI */
@@ -35,6 +35,7 @@ int main(int argc, char **argv){
   MPI_Comm_rank(MPI_COMM_WORLD, &rank);
 
   if(rank == 0){ /* Coordinator */
+    int CS_used = 0;
     while(1){
       MPI_Recv(&recv_buff, 1, MPI_INT, MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &status);
       if(status.MPI_TAG == REQUEST_TAG){