aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/simulator.cc20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/simulator.cc b/src/simulator.cc
index 7b288e4..02fbdc6 100644
--- a/src/simulator.cc
+++ b/src/simulator.cc
@@ -43,7 +43,7 @@
TRACK_UPTIME(m->put(hint_forward,0,TRY_FORWARD_DURING)); \
simgrid::s4u::Mailbox *m_ded= simgrid::s4u::Mailbox::by_name(hint_forward->DedicatedMailbox); \
MODE_TX(); \
- SEND(m_ded->put(hint_forward,0,uptime)); \
+ SEND(m_ded->put(hint_forward,i.hint_size,uptime)); \
} \
catch(...){ \
XBT_INFO("%s fail to forward a hint",CNAME); \
@@ -57,6 +57,8 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(simulator, "[DAO] Loosely Coupled DSS");
/// @brief For convenience sake
typedef unsigned int u32;
+u32 nON;
+bool *data_ready;
/**
* Data that will be exchange between the nodes
@@ -78,6 +80,13 @@ public:
/// @brief Observation node code
static void obs_node(std::vector<std::string> args);
+bool is_data_rcv_ready(){
+ for(int i=0;i<nON;i++){
+ if(data_ready[i])
+ return true;
+ }
+ return false;
+}
/**
* No arguments are require (cf inputs.json)
@@ -96,12 +105,15 @@ int main(int argc, char **argv) {
XBT_INFO("-------------------------------------------------");
// Init all nodes actors
- u32 nON=simgrid::s4u::Engine::get_instance()->get_host_count();
+ nON=simgrid::s4u::Engine::get_instance()->get_host_count();
+ data_ready=(bool*)malloc(sizeof(bool)*nON);
for(u32 i=0;i<nON;i++){
std::vector<std::string> args;
std::ostringstream ss;
ss<< "on" <<i;
- simgrid::s4u::Actor::create("ON", simgrid::s4u::Host::by_name(ss.str()), obs_node, args);
+ args.push_back(std::to_string(i));
+ data_ready[i]=false;
+ simgrid::s4u::Actor::create("obs_node", simgrid::s4u::Host::by_name(ss.str()), obs_node, args);
}
// Launch the simulation
@@ -117,6 +129,7 @@ int main(int argc, char **argv) {
static void obs_node(std::vector<std::string> args) {
// Init various variables
std::string selfName = simgrid::s4u::this_actor::get_host()->get_name();
+ int id=stoi(args[0]);
simgrid::s4u::this_actor::get_host()->turn_on();
Inputs i(selfName);
simgrid::s4u::Mailbox *m = simgrid::s4u::Mailbox::by_name("medium");
@@ -281,6 +294,7 @@ static void obs_node(std::vector<std::string> args) {
XBT_INFO("%s could not receive any data",CNAME);
nRcvFail++;
}
+ data_ready[id]=false;
}
forward_mode=!forward_mode; // Toggle mode (go back and forth between receiving and forwarding)
}