Lua can still be used to describe platforms
- Removed Java kernel plug-ins.
Will be reintroduced after the ongoing major internals reorg.
+ - In MSG
+ - the following functions were removed.
+ They were too specific and should be reimplemented in a generic
+ way, with filter function.
+ - MSG_task_listen_from_host
+ - MSG_mailbox_get_count_host_waiting_tasks
- In SimDag
- the SD_application_reinit function was removed. It was a noop for a while.
- The ACCESS_MODE of SD_workstation has been removed. This feature was not really usable and should soon be
static const double sleep_delay = 4.9999;
-extern long int smx_total_comms;
-
/* Finger element. */
typedef struct s_finger {
int id;
MSG_launch_application(application_file);
msg_error_t res = MSG_main();
- XBT_CRITICAL("Messages created: %ld", smx_total_comms);
XBT_INFO("Simulated time: %g", MSG_get_clock());
chord_exit();
> [115.044536] (2:node@node-1.acme.org) 40 | 366680
> [115.044536] (2:node@node-1.acme.org) 56 | 366680
> [115.044536] (2:node@node-1.acme.org) Predecessor: 1319738
-> [1151.814423] (0:maestro@) Messages created: 2452
> [1151.814423] (0:maestro@) Simulated time: 1151.81
> [130.161328] (3:node@node-2.acme.org) My finger table:
> [130.161328] (3:node@node-2.acme.org) Start | Succ
> [ 990.991700] (8:node@node-7.acme.org) 14199064 | 10004760
> [ 990.991700] (8:node@node-7.acme.org) 1616152 | 10004760
> [ 990.991700] (8:node@node-7.acme.org) Predecessor: 6518808
-> [1201.991400] (0:maestro@) Messages created: 2208
> [1201.991400] (0:maestro@) Simulated time: 1201.99
*/
XBT_LOG_NEW_DEFAULT_CATEGORY(msg_kademlia, "Messages specific for this msg example");
-extern long unsigned int smx_total_comms;
-
/* Main loop for the process */
static void main_loop(node_t node, double deadline)
{
msg_error_t res = MSG_main();
- XBT_CRITICAL("Messages created: %ld", smx_total_comms);
XBT_INFO("Simulated time: %g", MSG_get_clock());
return res != MSG_OK;
> [780.000000] (10:node@node-9.acme.org) 5/5 FIND_NODE have succeeded
> [780.000000] (12:node@node-11.acme.org) 6/6 FIND_NODE have succeeded
> [780.000000] ( 4:node@node-3.acme.org) 5/5 FIND_NODE have succeeded
-> [780.000000] ( 0:maestro@) Messages created: 1179
> [780.000000] ( 0:maestro@) Simulated time: 780
static int timeout = 50;
static int max_simulation_time = 1000;
-extern long int smx_total_comms;
-
typedef struct s_node {
int id; //128bits generated random(2^128 -1)
int known_id;
MSG_launch_application(options[1]);
msg_error_t res = MSG_main();
- XBT_CRITICAL("Messages created: %ld", smx_total_comms);
XBT_INFO("Simulated time: %g", MSG_get_clock());
return res != MSG_OK;
p Testing the Chord implementation with MSG
-! output sort 19
$ $SG_TEST_EXENV ${bindir:=.}/dht-pastry$EXEEXT -nb_bits=6 ${srcdir:=.}/../../platforms/platform.xml ${srcdir:=.}/dht-pastry_d.xml --cfg=network/crosstraffic:0 --log=msg_pastry.thres:verbose "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
XBT_PUBLIC(msg_error_t) MSG_comm_get_status(msg_comm_t comm);
XBT_PUBLIC(int) MSG_task_listen(const char *alias);
-XBT_PUBLIC(int) MSG_task_listen_from_host(const char *alias, msg_host_t host);
XBT_PUBLIC(msg_error_t) MSG_task_send_with_timeout(msg_task_t task, const char *alias, double timeout);
XBT_PUBLIC(msg_error_t) MSG_task_send_with_timeout_bounded(msg_task_t task, const char *alias, double timeout, double maxrate);
XBT_PUBLIC(msg_error_t) MSG_task_send(msg_task_t task, const char *alias);
*/
XBT_PUBLIC(msg_task_t) MSG_mailbox_get_head(msg_mailbox_t mailbox);
-/* @brief MSG_mailbox_get_count_host_waiting_tasks
- * Return the number of tasks waiting to be received in a mailbox and sent by a host.
- * @param mailbox The mailbox concerned by the operation.
- * @param host The host containing the processes that sended the tasks.
- * @return The number of tasks in the mailbox specified by the parameter mailbox and sended by all the
- * processes located on the host specified by the parameter host.
- */
-XBT_PUBLIC(int) MSG_mailbox_get_count_host_waiting_tasks(msg_mailbox_t mailbox, msg_host_t host);
XBT_PUBLIC(msg_error_t) MSG_mailbox_get_task_ext(msg_mailbox_t mailbox, msg_task_t * task, msg_host_t host,
double timeout);
XBT_PUBLIC(msg_error_t) MSG_mailbox_get_task_ext_bounded(msg_mailbox_t mailbox, msg_task_t *task, msg_host_t host,
/***** Rendez-vous points *****/
XBT_PUBLIC(smx_mailbox_t) simcall_mbox_create(const char *name);
-XBT_PUBLIC(void) simcall_mbox_destroy(smx_mailbox_t mbox);
XBT_PUBLIC(smx_mailbox_t) simcall_mbox_get_by_name(const char *name);
-XBT_PUBLIC(int) simcall_mbox_comm_count_by_host(smx_mailbox_t mbox, sg_host_t host);
XBT_PUBLIC(smx_synchro_t) simcall_mbox_get_head(smx_mailbox_t mbox);
XBT_PUBLIC(smx_process_t) simcall_mbox_get_receiver(smx_mailbox_t mbox);
XBT_PUBLIC(void) simcall_mbox_set_receiver(smx_mailbox_t mbox , smx_process_t process);
-XBT_PUBLIC(xbt_dict_t) SIMIX_get_mailboxes(void);
-
/***** Communication simcalls *****/
XBT_PUBLIC(void) simcall_comm_send(smx_process_t sender, smx_mailbox_t mbox, double task_size,
* asserts and stuff
* \param f a list (#xbt_fifo_t)
* \param i a bucket (#xbt_fifo_item_t)
- * \param type a type
* \param n an object of type \a type.
+ * \param type the type of objects contained in the fifo
* @hideinitializer
*
* Iterates over the whole list.
/** @brief Thread mutex data type (opaque object)
* @hideinitializer
*/
-typedef struct s_xbt_mutex_ *xbt_mutex_t;
+typedef struct s_smx_mutex_ *xbt_mutex_t;
/** @brief Creates a new mutex variable */
XBT_PUBLIC(xbt_mutex_t) xbt_mutex_init(void);
/** @brief Thread condition data type (opaque object)
* @hideinitializer
*/
-typedef struct s_xbt_cond_ *xbt_cond_t;
+typedef struct s_smx_cond_ *xbt_cond_t;
/** @brief Creates a condition variable */
XBT_PUBLIC(xbt_cond_t) xbt_cond_init(void);
return (jboolean) rv;
}
-JNIEXPORT jint JNICALL Java_org_simgrid_msg_Task_listenFromHost(JNIEnv * env, jclass cls, jstring jalias, jobject jhost)
-{
- int rv;
- const char *alias;
-
- msg_host_t host = jhost_get_native(env, jhost);
-
- if (!host) {
- jxbt_throw_notbound(env, "host", jhost);
- return -1;
- }
- alias = env->GetStringUTFChars(jalias, 0);
- rv = MSG_task_listen_from_host(alias, host);
- env->ReleaseStringUTFChars(jalias, alias);
-
- return (jint) rv;
-}
-
JNIEXPORT jint JNICALL Java_org_simgrid_msg_Task_listenFrom(JNIEnv * env, jclass cls, jstring jalias)
{
int rv;
*/
public native static boolean listen(String mailbox);
- /**
- * Counts the number of tasks waiting to be received on the \a mailbox identified by the specified alia and sended by the specified \a host.
- */
- public native static int listenFromHost(String alias, Host host);
-
/**
* Class initializer, to initialize various JNI stuff
*/
/* Static variable used for tracing */
process.ignore_global_variable("counter");
-
- /* SIMIX */
- process.ignore_global_variable("smx_total_comms");
}
void ModelChecker::shutdown()
*/
int MSG_task_listen(const char *alias)
{
- smx_mailbox_t rdv = MSG_mailbox_get_by_alias(alias);
- return !MSG_mailbox_is_empty(rdv) || (rdv->permanent_receiver && xbt_fifo_size(rdv->done_comm_fifo)!=0);
-}
-
-/** \ingroup msg_task_usage
- * \brief Check the number of communication actions of a given host pending in a mailbox.
- *
- * \param alias the name of the mailbox to be considered
- * \param host the host to check for communication
- *
- * \return Returns the number of pending communication actions of the host in the given mailbox, 0 if there is no
- * pending communication actions.
- */
-int MSG_task_listen_from_host(const char *alias, msg_host_t host)
-{
- return MSG_mailbox_get_count_host_waiting_tasks(MSG_mailbox_get_by_alias(alias), host);
+ smx_mailbox_t mbox = MSG_mailbox_get_by_alias(alias);
+ return !MSG_mailbox_is_empty(mbox) || (mbox->permanent_receiver && !mbox->done_comm_queue->empty());
}
/** \ingroup msg_task_usage
return simcall_mbox_create(alias);
}
-void MSG_mailbox_free(void *mailbox)
-{
- simcall_mbox_destroy((msg_mailbox_t)mailbox);
-}
-
int MSG_mailbox_is_empty(msg_mailbox_t mailbox)
{
return (NULL == simcall_mbox_get_head(mailbox));
return (msg_task_t) simcall_comm_get_src_data(comm);
}
-int MSG_mailbox_get_count_host_waiting_tasks(msg_mailbox_t mailbox, msg_host_t host)
-{
- return simcall_mbox_comm_count_by_host(mailbox, host);
-}
-
msg_mailbox_t MSG_mailbox_get_by_alias(const char *alias)
{
msg_mailbox_t mailbox = simcall_mbox_get_by_name(alias);
XBT_PRIVATE void MSG_host_add_task(msg_host_t host, msg_task_t task);
XBT_PRIVATE void MSG_host_del_task(msg_host_t host, msg_task_t task);
-/* @brief MSG_mailbox_free - release a mailbox from the memory.
- * Releases a mailbox from the memory but does not remove it from the dictionary.
- * @param mailbox The mailbox to release.
- */
-XBT_PRIVATE void MSG_mailbox_free(void *mailbox);
/********** Tracing **********/
/* declaration of instrumentation functions from msg_task_instr.c */
return simcall_BODY_mbox_create(name);
}
-
-/**
- * \ingroup simix_mbox_management
- * \brief Destroy a rendez-vous point
- * \param mbox The rendez-vous point to destroy
- */
-void simcall_mbox_destroy(smx_mailbox_t mbox)
-{
- simcall_BODY_mbox_destroy(mbox);
-}
/**
* \ingroup simix_mbox_management
* \brief Returns a rendez-vous point knowing its name
return SIMIX_mbox_get_by_name(name);
}
-/**
- * \ingroup simix_mbox_management
- * \brief Counts the number of communication synchros of a given host pending
- * on a rendez-vous point.
- * \param mbox The rendez-vous point
- * \param host The host to be counted
- * \return The number of comm synchros pending in the mbox
- */
-int simcall_mbox_comm_count_by_host(smx_mailbox_t mbox, sg_host_t host)
-{
- return simcall_BODY_mbox_comm_count_by_host(mbox, host);
-}
-
/**
* \ingroup simix_mbox_management
* \brief returns the communication at the head of the rendez-vous
simcall->result.dp = result;
}
-static inline smx_mailbox_t simcall_mbox_destroy__get__mbox(smx_simcall_t simcall) {
- return (smx_mailbox_t) simcall->args[0].dp;
-}
-static inline void simcall_mbox_destroy__set__mbox(smx_simcall_t simcall, void* arg) {
- simcall->args[0].dp = arg;
-}
-
-static inline smx_mailbox_t simcall_mbox_comm_count_by_host__get__mbox(smx_simcall_t simcall) {
- return (smx_mailbox_t) simcall->args[0].dp;
-}
-static inline void simcall_mbox_comm_count_by_host__set__mbox(smx_simcall_t simcall, void* arg) {
- simcall->args[0].dp = arg;
-}
-static inline sg_host_t simcall_mbox_comm_count_by_host__get__host(smx_simcall_t simcall) {
- return (sg_host_t) simcall->args[1].dp;
-}
-static inline void simcall_mbox_comm_count_by_host__set__host(smx_simcall_t simcall, void* arg) {
- simcall->args[1].dp = arg;
-}
-static inline unsigned int simcall_mbox_comm_count_by_host__get__result(smx_simcall_t simcall){
- return simcall->result.ui;
-}
-static inline void simcall_mbox_comm_count_by_host__set__result(smx_simcall_t simcall, unsigned int result){
- simcall->result.ui = result;
-}
-
static inline smx_mailbox_t simcall_mbox_get_head__get__mbox(smx_simcall_t simcall) {
return (smx_mailbox_t) simcall->args[0].dp;
}
return (smx_mailbox_t) self->simcall.result.dp;
}
-inline static void simcall_BODY_mbox_destroy(smx_mailbox_t mbox) {
- smx_process_t self = SIMIX_process_self();
-
- /* Go to that function to follow the code flow through the simcall barrier */
- if (0) SIMIX_mbox_destroy(mbox);
- /* end of the guide intended to the poor programmer wanting to go from MSG to Surf */
-
- self->simcall.call = SIMCALL_MBOX_DESTROY;
- memset(&self->simcall.result, 0, sizeof(self->simcall.result));
- memset(self->simcall.args, 0, sizeof(self->simcall.args));
- self->simcall.args[0].dp = (void*) mbox;
- if (self != simix_global->maestro_process) {
- XBT_DEBUG("Yield process '%s' on simcall %s (%d)", self->name,
- SIMIX_simcall_name(self->simcall.call), (int)self->simcall.call);
- SIMIX_process_yield(self);
- } else {
- SIMIX_simcall_handle(&self->simcall, 0);
- }
-
- }
-
-inline static unsigned int simcall_BODY_mbox_comm_count_by_host(smx_mailbox_t mbox, sg_host_t host) {
- smx_process_t self = SIMIX_process_self();
-
- /* Go to that function to follow the code flow through the simcall barrier */
- if (0) SIMIX_mbox_comm_count_by_host(mbox, host);
- /* end of the guide intended to the poor programmer wanting to go from MSG to Surf */
-
- self->simcall.call = SIMCALL_MBOX_COMM_COUNT_BY_HOST;
- memset(&self->simcall.result, 0, sizeof(self->simcall.result));
- memset(self->simcall.args, 0, sizeof(self->simcall.args));
- self->simcall.args[0].dp = (void*) mbox;
- self->simcall.args[1].dp = (void*) host;
- if (self != simix_global->maestro_process) {
- XBT_DEBUG("Yield process '%s' on simcall %s (%d)", self->name,
- SIMIX_simcall_name(self->simcall.call), (int)self->simcall.call);
- SIMIX_process_yield(self);
- } else {
- SIMIX_simcall_handle(&self->simcall, 0);
- }
- return (unsigned int) self->simcall.result.ui;
- }
-
inline static smx_synchro_t simcall_BODY_mbox_get_head(smx_mailbox_t mbox) {
smx_process_t self = SIMIX_process_self();
SIMCALL_PROCESS_AUTO_RESTART_SET,
SIMCALL_PROCESS_RESTART,
SIMCALL_MBOX_CREATE,
- SIMCALL_MBOX_DESTROY,
- SIMCALL_MBOX_COMM_COUNT_BY_HOST,
SIMCALL_MBOX_GET_HEAD,
SIMCALL_MBOX_SET_RECEIVER,
SIMCALL_MBOX_GET_RECEIVER,
"SIMCALL_PROCESS_AUTO_RESTART_SET",
"SIMCALL_PROCESS_RESTART",
"SIMCALL_MBOX_CREATE",
- "SIMCALL_MBOX_DESTROY",
- "SIMCALL_MBOX_COMM_COUNT_BY_HOST",
"SIMCALL_MBOX_GET_HEAD",
"SIMCALL_MBOX_SET_RECEIVER",
"SIMCALL_MBOX_GET_RECEIVER",
SIMIX_simcall_answer(simcall);
break;
-case SIMCALL_MBOX_DESTROY:
- SIMIX_mbox_destroy((smx_mailbox_t) simcall->args[0].dp);
- SIMIX_simcall_answer(simcall);
- break;
-
-case SIMCALL_MBOX_COMM_COUNT_BY_HOST:
- simcall->result.ui = SIMIX_mbox_comm_count_by_host((smx_mailbox_t) simcall->args[0].dp,(sg_host_t) simcall->args[1].dp);
- SIMIX_simcall_answer(simcall);
- break;
-
case SIMCALL_MBOX_GET_HEAD:
simcall->result.dp = SIMIX_mbox_get_head((smx_mailbox_t) simcall->args[0].dp);
SIMIX_simcall_answer(simcall);
Func H process_restart (void*, smx_process_t) (process, void*, smx_process_t)
Func - mbox_create (void*, smx_mailbox_t) (name, const char*)
-Proc - mbox_destroy (void) (mbox, void*, smx_mailbox_t)
-Func - mbox_comm_count_by_host (unsigned int) (mbox, void*, smx_mailbox_t) (host, void*, sg_host_t)
Func - mbox_get_head (void*, smx_synchro_t) (mbox, void*, smx_mailbox_t)
Proc - mbox_set_receiver (void) (mbox, void*, smx_mailbox_t) (receiver, void*, smx_process_t)
Func - mbox_get_receiver (void*, smx_process_t) (mbox, void*, smx_mailbox_t)
__xbt_running_ctx_fetch = SIMIX_process_get_running_context;
__xbt_ex_terminate = SIMIX_process_exception_terminate;
- SIMIX_network_init();
-
/* Prepare to display some more info when dying on Ctrl-C pressing */
signal(SIGINT, inthandler);
SIMIX_process_killall(simix_global->maestro_process, 1);
/* Exit the SIMIX network module */
- SIMIX_network_exit();
+ SIMIX_mailbox_exit();
xbt_heap_free(simix_timers);
simix_timers = NULL;
#include "mc/mc.h"
#include "src/mc/mc_replay.h"
#include "xbt/dict.h"
+#include "simgrid/s4u/mailbox.hpp"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_network, simix, "SIMIX network-related synchronization");
-static xbt_dict_t mailboxes = NULL;
-XBT_EXPORT_NO_IMPORT(unsigned long int) smx_total_comms = 0;
+static void SIMIX_mbox_free(void *data);
+static xbt_dict_t mailboxes = xbt_dict_new_homogeneous(SIMIX_mbox_free);
static void SIMIX_waitany_remove_simcall_from_actions(smx_simcall_t simcall);
static void SIMIX_comm_copy_data(smx_synchro_t comm);
static smx_synchro_t SIMIX_fifo_probe_comm(xbt_fifo_t fifo, e_smx_comm_type_t type,
int (*match_fun)(void *, void *,smx_synchro_t),
void *user_data, smx_synchro_t my_synchro);
-static smx_synchro_t SIMIX_fifo_get_comm(xbt_fifo_t fifo, e_smx_comm_type_t type,
+static smx_synchro_t SIMIX_deque_get_filtered(std::deque<smx_synchro_t> *deque, e_smx_comm_type_t type,
int (*match_fun)(void *, void *,smx_synchro_t),
void *user_data, smx_synchro_t my_synchro);
-static void SIMIX_mbox_free(void *data);
static void SIMIX_comm_start(smx_synchro_t synchro);
-void SIMIX_network_init(void)
-{
- mailboxes = xbt_dict_new_homogeneous(SIMIX_mbox_free);
-}
-
-void SIMIX_network_exit(void)
+void SIMIX_mailbox_exit(void)
{
xbt_dict_free(&mailboxes);
}
smx_mailbox_t SIMIX_mbox_create(const char *name)
{
+ xbt_assert(name, "Mailboxes must have a name");
/* two processes may have pushed the same mbox_create simcall at the same time */
- smx_mailbox_t mbox = name ? (smx_mailbox_t) xbt_dict_get_or_null(mailboxes, name) : NULL;
+ smx_mailbox_t mbox = (smx_mailbox_t) xbt_dict_get_or_null(mailboxes, name);
if (!mbox) {
mbox = xbt_new0(s_smx_mailbox_t, 1);
- mbox->name = name ? xbt_strdup(name) : NULL;
- mbox->comm_fifo = xbt_fifo_new();
- mbox->done_comm_fifo = xbt_fifo_new();
+ mbox->name = xbt_strdup(name);
+ mbox->comm_queue = new std::deque<smx_synchro_t>();
+ mbox->done_comm_queue = nullptr; // Allocated on need only
mbox->permanent_receiver=NULL;
XBT_DEBUG("Creating a mailbox at %p with name %s", mbox, name);
-
- if (mbox->name)
- xbt_dict_set(mailboxes, mbox->name, mbox, NULL);
+ xbt_dict_set(mailboxes, mbox->name, mbox, NULL);
}
return mbox;
}
-void SIMIX_mbox_destroy(smx_mailbox_t mbox)
-{
- if (mbox->name)
- xbt_dict_remove(mailboxes, mbox->name);
-}
-
void SIMIX_mbox_free(void *data)
{
XBT_DEBUG("mbox free %p", data);
smx_mailbox_t mbox = (smx_mailbox_t) data;
xbt_free(mbox->name);
- xbt_fifo_free(mbox->comm_fifo);
- xbt_fifo_free(mbox->done_comm_fifo);
+ delete mbox->comm_queue;
+ delete mbox->done_comm_queue;
xbt_free(mbox);
}
-xbt_dict_t SIMIX_get_mailboxes()
-{
- return mailboxes;
-}
-
smx_mailbox_t SIMIX_mbox_get_by_name(const char *name)
{
return (smx_mailbox_t) xbt_dict_get_or_null(mailboxes, name);
}
-int SIMIX_mbox_comm_count_by_host(smx_mailbox_t mbox, sg_host_t host)
-{
- smx_synchro_t comm = NULL;
- xbt_fifo_item_t item = NULL;
- int count = 0;
-
- xbt_fifo_foreach(mbox->comm_fifo, item, comm, smx_synchro_t) {
- if (comm->comm.src_proc->host == host)
- count++;
- }
-
- return count;
-}
-
smx_synchro_t SIMIX_mbox_get_head(smx_mailbox_t mbox)
{
- return (smx_synchro_t) xbt_fifo_get_item_content(
- xbt_fifo_get_first_item(mbox->comm_fifo));
+ return mbox->comm_queue->front();
}
/**
void SIMIX_mbox_set_receiver(smx_mailbox_t mbox, smx_process_t process)
{
mbox->permanent_receiver=process;
+ if (mbox->done_comm_queue == nullptr)
+ mbox->done_comm_queue = new std::deque<smx_synchro_t>();
}
/**
*/
static inline void SIMIX_mbox_push(smx_mailbox_t mbox, smx_synchro_t comm)
{
- xbt_fifo_push(mbox->comm_fifo, comm);
+ mbox->comm_queue->push_back(comm);
comm->comm.mbox = mbox;
}
*/
void SIMIX_mbox_remove(smx_mailbox_t mbox, smx_synchro_t comm)
{
- xbt_fifo_remove(mbox->comm_fifo, comm);
+ for (auto it = mbox->comm_queue->begin(); it != mbox->comm_queue->end(); it++)
+ if (*it == comm) {
+ mbox->comm_queue->erase(it);
+ break;
+ }
+
comm->comm.mbox = NULL;
}
/**
- * \brief Checks if there is a communication synchro queued in a fifo matching our needs
+ * \brief Checks if there is a communication synchro queued in a deque matching our needs
* \param type The type of communication we are looking for (comm_send, comm_recv)
* \return The communication synchro if found, NULL otherwise
*/
-smx_synchro_t SIMIX_fifo_get_comm(xbt_fifo_t fifo, e_smx_comm_type_t type,
- int (*match_fun)(void *, void *,smx_synchro_t),
- void *this_user_data, smx_synchro_t my_synchro)
+static smx_synchro_t
+SIMIX_deque_get_filtered(std::deque<smx_synchro_t> *deque, e_smx_comm_type_t type,
+ int (*match_fun)(void *, void *,smx_synchro_t),
+ void *this_user_data, smx_synchro_t my_synchro)
{
- smx_synchro_t synchro;
- xbt_fifo_item_t item;
void* other_user_data = NULL;
- xbt_fifo_foreach(fifo, item, synchro, smx_synchro_t) {
+ for(auto it = deque->begin(); it != deque->end(); it++){
+ smx_synchro_t synchro = *it;
if (synchro->comm.type == SIMIX_COMM_SEND) {
other_user_data = synchro->comm.src_data;
} else if (synchro->comm.type == SIMIX_COMM_RECEIVE) {
(!match_fun || match_fun(this_user_data, other_user_data, synchro)) &&
(!synchro->comm.match_fun || synchro->comm.match_fun(other_user_data, this_user_data, my_synchro))) {
XBT_DEBUG("Found a matching communication synchro %p", synchro);
- xbt_fifo_remove_item(fifo, item);
- xbt_fifo_free_item(item);
+ deque->erase(it);
synchro->comm.refcount++;
#if HAVE_MC
synchro->comm.mbox_cpy = synchro->comm.mbox;
synchro->category = NULL;
XBT_DEBUG("Create communicate synchro %p", synchro);
- ++smx_total_comms;
return synchro;
}
* ourself so that the other side also gets a chance of choosing if it wants to match with us.
*
* If it is not found then push our communication into the rendez-vous point */
- smx_synchro_t other_synchro = SIMIX_fifo_get_comm(mbox->comm_fifo, SIMIX_COMM_RECEIVE, match_fun, data, this_synchro);
+ smx_synchro_t other_synchro = SIMIX_deque_get_filtered(mbox->comm_queue, SIMIX_COMM_RECEIVE, match_fun, data, this_synchro);
if (!other_synchro) {
other_synchro = this_synchro;
other_synchro->state = SIMIX_READY;
other_synchro->comm.dst_proc=mbox->permanent_receiver;
other_synchro->comm.refcount++;
- xbt_fifo_push(mbox->done_comm_fifo,other_synchro);
+ mbox->done_comm_queue->push_back(other_synchro);
other_synchro->comm.mbox=mbox;
XBT_DEBUG("pushing a message into the permanent receive fifo %p, comm %p", mbox, &(other_synchro->comm));
XBT_DEBUG("Receive already pushed");
SIMIX_comm_destroy(this_synchro);
- --smx_total_comms; // this creation was a pure waste
other_synchro->state = SIMIX_READY;
other_synchro->comm.type = SIMIX_COMM_READY;
void (*copy_data_fun)(smx_synchro_t, void*, size_t), // used to copy data if not default one
void *data, double rate)
{
- XBT_DEBUG("recv from %p %p", mbox, mbox->comm_fifo);
+ XBT_DEBUG("recv from %p %p", mbox, mbox->comm_queue);
smx_synchro_t this_synchro = SIMIX_comm_new(SIMIX_COMM_RECEIVE);
smx_synchro_t other_synchro;
//communication already done, get it inside the fifo of completed comms
- if (mbox->permanent_receiver && xbt_fifo_size(mbox->done_comm_fifo)!=0) {
+ if (mbox->permanent_receiver && ! mbox->done_comm_queue->empty()) {
XBT_DEBUG("We have a comm that has probably already been received, trying to match it, to skip the communication");
//find a match in the already received fifo
- other_synchro = SIMIX_fifo_get_comm(mbox->done_comm_fifo, SIMIX_COMM_SEND, match_fun, data, this_synchro);
+ other_synchro = SIMIX_deque_get_filtered(mbox->done_comm_queue, SIMIX_COMM_SEND, match_fun, data, this_synchro);
//if not found, assume the receiver came first, register it to the mailbox in the classical way
if (!other_synchro) {
XBT_DEBUG("We have messages in the permanent receive list, but not the one we are looking for, pushing request into fifo");
}
other_synchro->comm.refcount--;
SIMIX_comm_destroy(this_synchro);
- --smx_total_comms; // this creation was a pure waste
}
} else {
/* Prepare a synchro describing us, so that it gets passed to the user-provided filter of other side */
* ourself so that the other side also gets a chance of choosing if it wants to match with us.
*
* If it is not found then push our communication into the rendez-vous point */
- other_synchro = SIMIX_fifo_get_comm(mbox->comm_fifo, SIMIX_COMM_SEND, match_fun, data, this_synchro);
+ other_synchro = SIMIX_deque_get_filtered(mbox->comm_queue, SIMIX_COMM_SEND, match_fun, data, this_synchro);
if (!other_synchro) {
- XBT_DEBUG("Receive pushed first %d", xbt_fifo_size(mbox->comm_fifo));
+ XBT_DEBUG("Receive pushed first %lu", mbox->comm_queue->size());
other_synchro = this_synchro;
SIMIX_mbox_push(mbox, this_synchro);
} else {
SIMIX_comm_destroy(this_synchro);
- --smx_total_comms; // this creation was a pure waste
other_synchro->state = SIMIX_READY;
other_synchro->comm.type = SIMIX_COMM_READY;
//other_synchro->comm.refcount--;
smx_synchro_t SIMIX_comm_iprobe(smx_process_t dst_proc, smx_mailbox_t mbox, int type, int src,
int tag, int (*match_fun)(void *, void *, smx_synchro_t), void *data)
{
- XBT_DEBUG("iprobe from %p %p", mbox, mbox->comm_fifo);
+ XBT_DEBUG("iprobe from %p %p", mbox, mbox->comm_queue);
smx_synchro_t this_synchro;
int smx_type;
if(type == 1){
smx_type = SIMIX_COMM_SEND;
}
smx_synchro_t other_synchro=NULL;
- if(mbox->permanent_receiver && xbt_fifo_size(mbox->done_comm_fifo)!=0){
+ if(mbox->permanent_receiver && ! mbox->done_comm_queue->empty()){
//find a match in the already received fifo
- XBT_DEBUG("first try in the perm recv mailbox");
+ XBT_DEBUG("first check in the perm recv mailbox");
- other_synchro = SIMIX_fifo_probe_comm(
- mbox->done_comm_fifo, (e_smx_comm_type_t) smx_type,
- match_fun, data, this_synchro);
+ other_synchro = SIMIX_deque_get_filtered(mbox->done_comm_queue, (e_smx_comm_type_t) smx_type, match_fun, data, this_synchro);
}
// }else{
- if(!other_synchro){
+ if (!other_synchro){
XBT_DEBUG("try in the normal mailbox");
- other_synchro = SIMIX_fifo_probe_comm(
- mbox->comm_fifo, (e_smx_comm_type_t) smx_type,
- match_fun, data, this_synchro);
+ other_synchro = SIMIX_deque_get_filtered(mbox->comm_queue, (e_smx_comm_type_t) smx_type, match_fun, data, this_synchro);
}
// }
if(other_synchro)other_synchro->comm.refcount--;
SIMIX_comm_destroy(this_synchro);
- --smx_total_comms;
return other_synchro;
}
#ifndef _SIMIX_NETWORK_PRIVATE_H
#define _SIMIX_NETWORK_PRIVATE_H
+#include <deque>
#include <xbt/base.h>
#include "simgrid/simix.h"
/** @brief Rendez-vous point datatype */
typedef struct s_smx_mailbox {
char *name;
- xbt_fifo_t comm_fifo;
+ std::deque<smx_synchro_t> *comm_queue;
void *data;
smx_process_t permanent_receiver; //process which the mailbox is attached to
- xbt_fifo_t done_comm_fifo;//messages already received in the permanent receive mode
+ std::deque<smx_synchro_t> *done_comm_queue;//messages already received in the permanent receive mode
} s_smx_mailbox_t;
-XBT_PRIVATE void SIMIX_network_init(void);
-XBT_PRIVATE void SIMIX_network_exit(void);
+XBT_PRIVATE void SIMIX_mailbox_exit(void);
XBT_PRIVATE smx_mailbox_t SIMIX_mbox_create(const char *name);
-XBT_PRIVATE void SIMIX_mbox_destroy(smx_mailbox_t mbox);
XBT_PRIVATE smx_mailbox_t SIMIX_mbox_get_by_name(const char *name);
XBT_PRIVATE void SIMIX_mbox_remove(smx_mailbox_t mbox, smx_synchro_t comm);
-XBT_PRIVATE int SIMIX_mbox_comm_count_by_host(smx_mailbox_t mbox, sg_host_t host);
XBT_PRIVATE smx_synchro_t SIMIX_mbox_get_head(smx_mailbox_t mbox);
XBT_PRIVATE void SIMIX_mbox_set_receiver(smx_mailbox_t mbox, smx_process_t proc);
XBT_PRIVATE smx_process_t SIMIX_mbox_get_receiver(smx_mailbox_t mbox);
smpi_comm_destroy(process_data[i]->comm_intra);
}
xbt_os_timer_free(process_data[i]->timer);
- simcall_mbox_destroy(process_data[i]->mailbox);
- simcall_mbox_destroy(process_data[i]->mailbox_small);
xbt_mutex_destroy(process_data[i]->mailboxes_mutex);
xbt_free(process_data[i]);
}
#include "xbt/synchro_core.h"
#include "simgrid/simix.h" /* used implementation */
-#include "../simix/smx_private.h" /* FIXME */
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_sync, xbt, "Synchronization mechanism");
/****** mutex related functions ******/
-struct s_xbt_mutex_ {
- s_smx_mutex_t mutex;
-};
-
xbt_mutex_t xbt_mutex_init(void)
{
return (xbt_mutex_t) simcall_mutex_init();
}
/***** condition related functions *****/
-struct s_xbt_cond_ {
- s_smx_cond_t cond;
-};
-
xbt_cond_t xbt_cond_init(void)
{
return (xbt_cond_t) simcall_cond_init();