mirror of
https://gitlab.com/manzerbredes/loosely-coupled-dss.git
synced 2025-04-25 06:48:33 +00:00
Debug
This commit is contained in:
parent
738f22d12f
commit
404eb004ad
7 changed files with 7568 additions and 1925 deletions
src
|
@ -56,7 +56,15 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(simulator, "[DAO] Loosely Coupled DSS");
|
|||
|
||||
/// @brief For convenience sake
|
||||
typedef unsigned int u32;
|
||||
|
||||
u32 nON;
|
||||
bool *data_ready;
|
||||
bool is_data_rcv_ready(){
|
||||
for(int i=0;i<nON;i++){
|
||||
if(data_ready[i])
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Data that will be exchange between the nodes
|
||||
*/
|
||||
|
@ -92,11 +100,14 @@ 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;
|
||||
args.push_back(std::to_string(i));
|
||||
data_ready[i]=false;
|
||||
simgrid::s4u::Actor::create("ON", simgrid::s4u::Host::by_name(ss.str()), obs_node, args);
|
||||
}
|
||||
|
||||
|
@ -113,6 +124,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");
|
||||
|
@ -167,7 +179,11 @@ static void obs_node(std::vector<std::string> args) {
|
|||
MODE_TX();
|
||||
// Then try sending the data
|
||||
if(i.extended){
|
||||
SEND(m_ded->put(p,i.data_size));
|
||||
if(is_data_rcv_ready()){
|
||||
SEND(m_ded->put(p,i.data_size));
|
||||
}
|
||||
else
|
||||
throw "Attemps to send when no receiver available in extended mode";
|
||||
}
|
||||
else{
|
||||
SEND(m_ded->put(p,i.data_size,uptime));
|
||||
|
@ -226,8 +242,10 @@ static void obs_node(std::vector<std::string> args) {
|
|||
hint_forward=new Payload(*p); // Enable hint forwarding
|
||||
hintReceived=true;
|
||||
}
|
||||
if(i.extended)
|
||||
data_ready[id]=true; // Say to the receiver that he can send (to avoid deadlock in extended mode)
|
||||
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
|
||||
// If we reach here, data has been received successfully
|
||||
|
@ -244,16 +262,46 @@ static void obs_node(std::vector<std::string> args) {
|
|||
hint_added++;
|
||||
}
|
||||
}
|
||||
data_ready[id]=false;
|
||||
}
|
||||
forward_mode=!forward_mode; // Toggle mode (go back and forth between receiving and forwarding)
|
||||
}
|
||||
else {
|
||||
XBT_INFO("%s is observing his environment...",CNAME);
|
||||
MODE_ON();
|
||||
if(hint_forward!=NULL && CLOCK < hint_forward->hint){
|
||||
FORWARD_HINT(uptime);
|
||||
if(i.use_hint){
|
||||
double try_for=forward_mode ? 1 : 1;
|
||||
try_for=try_for>uptime ? uptime : try_for;
|
||||
|
||||
if(forward_mode && hint_forward!=NULL && CLOCK < hint_forward->hint){
|
||||
FORWARD_HINT(try_for);
|
||||
}
|
||||
else {
|
||||
Payload *p;
|
||||
try {
|
||||
do {
|
||||
TRACK_UPTIME(p=m->get<Payload>(try_for));
|
||||
} while(p->HisForward); // Ignore forwarded hint
|
||||
simgrid::s4u::Mailbox *m_ded= simgrid::s4u::Mailbox::by_name(p->DedicatedMailbox);
|
||||
// Start receiving hint from sender
|
||||
MODE_RX();
|
||||
if(p->HasHint){
|
||||
TRACK_UPTIME(p=m_ded->get<Payload>(uptime));
|
||||
XBT_INFO("%s received a hint successfully",CNAME);
|
||||
hint_forward=new Payload(*p); // Enable hint forwarding
|
||||
//simgrid::s4u::this_actor::sleep_for(uptime); // Now sleep until the end
|
||||
}
|
||||
else {
|
||||
simgrid::s4u::this_actor::sleep_for(try_for);
|
||||
}
|
||||
}
|
||||
catch(...){
|
||||
}
|
||||
|
||||
}
|
||||
forward_mode=!forward_mode;
|
||||
}
|
||||
else{
|
||||
else {
|
||||
simgrid::s4u::this_actor::sleep_for(uptime);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue