#include <msg/msg.h>
#include <simgrid/modelchecker.h>
+
#define N 3
XBT_LOG_NEW_DEFAULT_CATEGORY(example, "this example");
int server(int argc, char *argv[])
{
- m_task_t task = NULL;
+ msg_task_t task = NULL;
int count = 0;
while (count < N) {
if (task) {
int client(int argc, char *argv[])
{
- m_task_t task =
+ msg_task_t task =
MSG_task_create(argv[1], 0 /*comp cost */ , 10000 /*comm size */ ,
NULL /*arbitrary data */ );
int CS_used = 0;
while (1) {
- m_task_t task = NULL;
+ msg_task_t task = NULL;
MSG_task_receive(&task, "coordinator");
const char *kind = MSG_task_get_name(task);
if (!strcmp(kind, "request")) {
} else {
if(strcmp(req, "2") == 0){
XBT_INFO("CS idle. Grant immediatly");
- m_task_t answer = MSG_task_create("grant", 0, 1000, NULL);
+ msg_task_t answer = MSG_task_create("grant", 0, 1000, NULL);
MSG_task_send(answer, req);
CS_used = 1;
}
}
- m_task_t grant = NULL;
+ msg_task_t grant = NULL;
MSG_task_receive(&grant, my_mailbox);
const char *kind = MSG_task_get_name(grant);
int server(int argc, char *argv[])
{
- m_task_t task1 = NULL;
- m_task_t task2 = NULL;
+ msg_task_t task1 = NULL;
+ msg_task_t task2 = NULL;
long val1, val2;
MSG_task_receive(&task1, "mymailbox");
int client(int argc, char *argv[])
{
- m_task_t task1 =
+ msg_task_t task1 =
MSG_task_create("task", 0, 10000, (void *) atol(argv[1]));
- m_task_t task2 =
+ msg_task_t task2 =
MSG_task_create("task", 0, 10000, (void *) atol(argv[1]));
XBT_INFO("Send %d!", atoi(argv[1]));
int CS_used = 0;
while(1) {
- m_task_t task = NULL;
+ msg_task_t task = NULL;
MSG_task_receive(&task, "coordinator");
const char *kind = MSG_task_get_name(task);
if (!strcmp(kind, "request")) {
char *req = MSG_task_get_data(task);
if (CS_used) {
- XBT_INFO("CS already used. Queue the request");
- xbt_dynar_push(requests, &req);
+ XBT_INFO("CS already used. Queue the request");
+ xbt_dynar_push(requests, &req);
} else {
- m_task_t answer = MSG_task_create("grant", 0, 1000, NULL);
- MSG_task_send(answer, req);
- CS_used = 1;
- XBT_INFO("CS idle. Grant immediatly");
+ msg_task_t answer = MSG_task_create("grant", 0, 1000, NULL);
+ MSG_task_send(answer, req);
+ CS_used = 1;
+ XBT_INFO("CS idle. Grant immediatly");
}
} else {
if (xbt_dynar_length(requests) > 0) {
- XBT_INFO("CS release. Grant to queued requests");
- char *req;
- xbt_dynar_pop(requests, &req);
- MSG_task_send(MSG_task_create("grant", 0, 1000, NULL), req);
+ XBT_INFO("CS release. Grant to queued requests");
+ char *req;
+ xbt_dynar_pop(requests, &req);
+ MSG_task_send(MSG_task_create("grant", 0, 1000, NULL), req);
} else {
- XBT_INFO("CS_realase, ressource now idle");
- CS_used = 0;
+ XBT_INFO("CS_realase, ressource now idle");
+ CS_used = 0;
}
}
MSG_task_send(MSG_task_create("request", 0, 1000, my_mailbox), "coordinator");
/* Wait the answer */
- m_task_t grant = NULL;
+ msg_task_t grant = NULL;
MSG_task_receive(&grant, my_mailbox);
MSG_task_destroy(grant);
XBT_INFO("cready = 1");
/* Wait the answer */
- m_task_t grant = NULL;
+ msg_task_t grant = NULL;
MSG_task_receive(&grant, my_mailbox);
MSG_task_destroy(grant);
int server(int argc, char *argv[])
{
- m_task_t task1;
+ msg_task_t task1;
long val1;
msg_comm_t comm1, comm2;
{
msg_comm_t comm;
char *mbox;
- m_task_t task1 =
+ msg_task_t task1 =
MSG_task_create("task", 0, 10000, (void *) atol(argv[1]));
mbox = bprintf("mymailbox%s", argv[1]);
int CS_used = 0; // initially the CS is idle
while (1) {
- m_task_t task = NULL;
+ msg_task_t task = NULL;
MSG_task_receive(&task, "coordinator");
const char *kind = MSG_task_get_name(task); //is it a request or a release?
if (!strcmp(kind, "request")) { // that's a request
char *req = MSG_task_get_data(task);
if (CS_used) {
XBT_INFO("CS already used.");
- m_task_t answer = MSG_task_create("not grant", 0, 1000, NULL);
+ msg_task_t answer = MSG_task_create("not grant", 0, 1000, NULL);
MSG_task_send(answer, req);
} else { // can serve it immediatly
XBT_INFO("CS idle. Grant immediatly");
- m_task_t answer = MSG_task_create("grant", 0, 1000, NULL);
+ msg_task_t answer = MSG_task_create("grant", 0, 1000, NULL);
MSG_task_send(answer, req);
CS_used = 1;
}
MSG_task_send(MSG_task_create("request", 0, 1000, my_mailbox),
"coordinator");
// wait the answer
- m_task_t answer = NULL;
+ msg_task_t answer = NULL;
MSG_task_receive(&answer, my_mailbox);
kind = MSG_task_get_name(answer);
int CS_used = 0; // initially the CS is idle
while (1) {
- m_task_t task = NULL;
+ msg_task_t task = NULL;
MSG_task_receive(&task, "coordinator");
const char *kind = MSG_task_get_name(task); //is it a request or a release?
if (!strcmp(kind, "request")) { // that's a request
xbt_dynar_push(requests, &req);
} else { // can serve it immediatly
XBT_INFO("CS idle. Grant immediatly");
- m_task_t answer = MSG_task_create("grant", 0, 1000, NULL);
+ msg_task_t answer = MSG_task_create("grant", 0, 1000, NULL);
MSG_task_send(answer, req);
CS_used = 1;
}
MSG_task_send(MSG_task_create("request", 0, 1000, my_mailbox),
"coordinator");
// wait the answer
- m_task_t grant = NULL;
+ msg_task_t grant = NULL;
MSG_task_receive(&grant, my_mailbox);
MSG_task_destroy(grant);
int CS_used = 0; // initially the CS is idle
int todo = AMOUNT_OF_CLIENTS * CS_PER_PROCESS; // amount of releases we are expecting
while (todo > 0) {
- m_task_t task = NULL;
+ msg_task_t task = NULL;
MSG_task_receive(&task, "coordinator");
const char *kind = MSG_task_get_name(task); //is it a request or a release?
if (!strcmp(kind, "request")) { // that's a request
xbt_dynar_push(requests, &req);
} else { // can serve it immediatly
XBT_INFO("CS idle. Grant immediatly");
- m_task_t answer = MSG_task_create("grant", 0, 1000, NULL);
+ msg_task_t answer = MSG_task_create("grant", 0, 1000, NULL);
MSG_task_send(answer, req);
CS_used = 1;
}
MSG_task_send(MSG_task_create("request", 0, 1000, my_mailbox),
"coordinator");
// wait the answer
- m_task_t grant = NULL;
+ msg_task_t grant = NULL;
MSG_task_receive(&grant, my_mailbox);
MSG_task_destroy(grant);
XBT_INFO("got the answer. Sleep a bit and release it");
while(i>0){
- m_task_t task = NULL;
+ msg_task_t task = NULL;
MSG_task_receive(&task, "coordinator");
const char *kind = MSG_task_get_name(task);
if (!strcmp(kind, "request")) {
char *req = MSG_task_get_data(task);
- m_task_t answer = MSG_task_create("received", 0, 1000, NULL);
+ msg_task_t answer = MSG_task_create("received", 0, 1000, NULL);
MSG_task_send(answer, req);
}else{
XBT_INFO("End of coordinator");
check();
// wait the answer
- m_task_t task = NULL;
+ msg_task_t task = NULL;
MSG_task_receive(&task, my_mailbox);
MSG_task_destroy(task);