-}
-
-int consumer(int argc, char *argv[])
-{
-
- char * my_mailbox = bprintf("%s", argv[1]);
- char *mess;
-
-
- //while(1) {
-
- /* CS request */
- XBT_INFO("Consumer ask the request");
- MSG_task_send(MSG_task_create("request", 0, 1000, my_mailbox), "coordinator");
-
- /* 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 */
- XBT_INFO("Message : %s", mess);
- if(strcmp(mess, "") != 0)
- consume = 1;
-
- cready = 0;
-
- free(mess);
-
- //consume = 0;
- //cready = 0;
+ if (!strcmp(kind, "grant")) {
+ XBT_INFO("Client (%s) got the answer (grant). Sleep a bit and release it", my_mailbox);
+ if(!strcmp(my_mailbox, "1"))
+ cs = 1;
+ }else{
+ XBT_INFO("Client (%s) got the answer (not grant). Try again", my_mailbox);
+ }