Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
model-checker : example bugged2_liveness modified
authorMarion Guthmuller <marion.guthmuller@loria.fr>
Thu, 23 Feb 2012 16:10:19 +0000 (17:10 +0100)
committerMarion Guthmuller <marion.guthmuller@loria.fr>
Thu, 23 Feb 2012 16:10:19 +0000 (17:10 +0100)
examples/msg/mc/bugged2_liveness.c
examples/msg/mc/deploy_bugged2_liveness.xml

index 305771f..9842999 100644 (file)
@@ -81,10 +81,12 @@ int producer(int argc, char *argv[])
 
   char * my_mailbox = bprintf("%s", argv[1]);
   
-  //while(1) {
+  while(1) {
     
     /* Create message */
     const char *mess = "message";
+
+    pready = 1;
     
     /* CS request */
     XBT_INFO("Producer ask the request");
@@ -95,21 +97,18 @@ int producer(int argc, char *argv[])
     MSG_task_receive(&grant, my_mailbox);
     MSG_task_destroy(grant);
 
-    pready = 1;
-
     /* Push message (size of buffer = 1) */
     buffer = strdup(mess);
 
+    produce = 1;
+
     /* CS release */
     MSG_task_send(MSG_task_create("release", 0, 1000, my_mailbox), "coordinator");
 
-    produce = 1;
+    produce = 0;
     pready = 0;
 
-    //produce = 0;
-    //pready = 0;
-
-    //}
+  }
 
   return 0;
 
@@ -122,40 +121,38 @@ int consumer(int argc, char *argv[])
   char *mess;
 
 
-  //while(1) {
+  while(1) {
     
     /* CS request */
     XBT_INFO("Consumer ask the request");
     MSG_task_send(MSG_task_create("request", 0, 1000, my_mailbox), "coordinator");
 
+    cready = 1;
+
     /* Wait the answer */
     m_task_t grant = NULL;
     MSG_task_receive(&grant, my_mailbox);
     MSG_task_destroy(grant);
 
-    cready = 1;
-
     /* Pop message  */
     mess = malloc(8*sizeof(char));
     mess = strdup(buffer);
     buffer[0] = '\0'; 
 
-    /* CS release */
-    MSG_task_send(MSG_task_create("release", 0, 1000, my_mailbox), "coordinator");
-
-    /* Display message */
+     /* Display message */
     XBT_INFO("Message : %s", mess);
     if(strcmp(mess, "") != 0)
       consume = 1;
 
-    cready = 0;
+    /* CS release */
+    MSG_task_send(MSG_task_create("release", 0, 1000, my_mailbox), "coordinator");
 
     free(mess);
 
-    //consume = 0;
-    //cready = 0;
+    consume = 0;
+    cready = 0;
 
-    //}
+  }
 
   return 0;
 
index f49fb10..3aa65c1 100644 (file)
@@ -6,11 +6,11 @@
 
   <process host="Tremblay" function="coordinator" />
 
-  <process host="Fafard" function="consumer" >
+  <process host="Fafard" function="producer" >
     <argument value="1"/>
   </process>
 
-  <process host="Boivin" function="producer" >
+  <process host="Boivin" function="consumer" >
     <argument value="2"/>
   </process>