#include <cstdio> // sprintf
#include <time.h> // clock()
#include <msg/msg.h>
+#define XBT_LOG_OLD_STYLE
#include <xbt/log.h>
+#include "simgrid_features.h"
// Creates a new log category and makes it the default
XBT_LOG_NEW_DEFAULT_CATEGORY(simu, "Simulation messages");
EXIT_FAILURE_CLEAN = 0x08, // error at cleanup
};
-int sender(int, char *[])
+int sender(int, char* [])
{
char mbox_stack[N_MBOX][100];
msg_comm_t comm_stack[N_MBOX * N_MESG];
- msg_comm_t *comm = comm_stack;
+ msg_comm_t* pcomm = comm_stack;
for (int i = 0 ; i < N_MBOX ; i++)
sprintf(mbox_stack[i], "MBox_%02d", i);
for (int i = 0 ; i < N_MBOX ; i++)
for (int j = 0 ; j < N_MESG ; j++) {
char task_name[100];
- const char *mailbox = mbox_stack[i];
+ const char* mailbox = mbox_stack[i];
unsigned shift = j;
unsigned comm_size = 1 << shift;
m_task_t task;
INFO4("At %02d, send %s, size %.0f to \"%s\"", n,
MSG_task_get_name(task),
MSG_task_get_data_size(task), mailbox);
- *comm++ = MSG_task_isend(task, mailbox);
+ *pcomm++ = MSG_task_isend(task, mailbox);
++n;
}
INFO0("Wait for communications to terminate...");
- MSG_comm_waitall(comm_stack, comm - comm_stack, -1.0);
+ MSG_comm_waitall(comm_stack, pcomm - comm_stack, -1.0);
+ if (!MSG_WAIT_DESTROYS_COMMS) {
+ while (pcomm > comm_stack)
+ MSG_comm_destroy(*--pcomm);
+ }
INFO0("Finished.");
return 0;
}
-int receiver(int, char *[])
+int receiver(int, char* [])
{
char mbox[N_MBOX][100];
int comm_count[N_MBOX];
}
}
int n = 0;
- while (xbt_dynar_length(dcomms)) {
+ while (!xbt_dynar_is_empty(dcomms)) {
MSG_comm_waitany(dcomms);
xbt_dynar_reset(dcomms);
for (int i = 0 ; i < N_MBOX ; i++) {
return 0;
}
-int main(int argc, char *argv[])
+int main(int argc, char* argv[])
{
- const char *platform_file;
- const char *application_file;
+ const char* platform_file;
+ const char* application_file;
// Note: variables used after THROW must be declared as volatile.
volatile int exit_status; // global exit status
volatile double simulated_time = -1.0;