aboutsummaryrefslogtreecommitdiff
path: root/src/simulator.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/simulator.cc')
-rw-r--r--src/simulator.cc16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/simulator.cc b/src/simulator.cc
index d6c8882..aedf810 100644
--- a/src/simulator.cc
+++ b/src/simulator.cc
@@ -8,6 +8,7 @@
#include <sstream>
#include "Inputs.hpp"
+#include "simgrid/s4u/Actor.hpp"
#define PLATFORM_FILE "platform.xml"
@@ -25,10 +26,8 @@
}
#define TRACK_UPTIME(instruction) \
{ \
- double uptimeTrack=CLOCK; \
instruction; \
- uptimeTrack=CLOCK-uptimeTrack; \
- uptime-=uptimeTrack; \
+ uptime=upuntil-CLOCK; \
uptime=uptime > 0 ? uptime : 0; \
}
/// @brief Note that we need to simulate latency our self since we need to send instantaneous messages
@@ -54,6 +53,7 @@
catch(...){ \
XBT_INFO("%s fail to forward a hint",CNAME); \
MODE_ON(); \
+ uptime=upuntil-CLOCK; \
TRACK_UPTIME(simgrid::s4u::this_actor::sleep_for(FOR(TRY_FORWARD_DURING))); \
} \
} \
@@ -156,7 +156,7 @@ static void obs_node(std::vector<std::string> args) {
bool forward_mode=false; // Turned on and off every x seconds by the receiver (to switch between forward hint mode and receiving data mode)
bool forward_only=false; // When observer receive a hint it switch to forward only up to the next wake up time
bool sendhint_mode=false; // Turned on and off every x seconds by the sender (to switch between send hint and send data)
- while(uptime>0)
+ while(CLOCK < upuntil)
{
// ---------- SENDER ----------
if(is_sender){
@@ -273,8 +273,9 @@ static void obs_node(std::vector<std::string> args) {
if(i.extended){
p=m_ded->get<Payload>(); // Fetch data until sended
}
- else
- p=m_ded->get<Payload>(uptime); // Fetch data until sended or uptime expire
+ else{
+ TRACK_UPTIME(p=m_ded->get<Payload>(uptime)); // Fetch data until sended or uptime expire
+ }
// If we reach here, data has been received successfully
XBT_INFO("%s received data successfully",CNAME);
timeDataRcv=CLOCK;
@@ -335,10 +336,11 @@ static void obs_node(std::vector<std::string> args) {
forward_mode=!forward_mode;
}
else {
- simgrid::s4u::this_actor::sleep_for(uptime);
+ simgrid::s4u::this_actor::sleep_until(upuntil);
}
}
uptime=upuntil-CLOCK; // Note that uptime can be < 0 in extended mode
+ uptime=uptime > 0 ? uptime : 0; // Just in case
}
// Load next event
i.GotoNextEvent();