X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/7a25b8e6a7aae6d40849189e58495aee0d8f726f..a1ba88402bfb88a278d2e7c849441a9ed4a26120:/src/simix/smx_network.c diff --git a/src/simix/smx_network.c b/src/simix/smx_network.c index 41192b6e23..d1c83d3f07 100644 --- a/src/simix/smx_network.c +++ b/src/simix/smx_network.c @@ -19,8 +19,6 @@ static void SIMIX_comm_finish(smx_action_t action); static void SIMIX_waitany_req_remove_from_actions(smx_req_t req); static void SIMIX_comm_copy_data(smx_action_t comm); static smx_action_t SIMIX_comm_new(e_smx_comm_type_t type); -static XBT_INLINE void SIMIX_comm_wait_for_completion(smx_action_t comm, - double timeout); static XBT_INLINE void SIMIX_rdv_push(smx_rdv_t rdv, smx_action_t comm); static XBT_INLINE void SIMIX_rdv_remove(smx_rdv_t rdv, smx_action_t comm); static smx_action_t SIMIX_rdv_get_request(smx_rdv_t rdv, e_smx_comm_type_t type, @@ -51,8 +49,8 @@ smx_rdv_t SIMIX_rdv_create(const char *name) rdv->name = name ? xbt_strdup(name) : NULL; rdv->comm_fifo = xbt_fifo_new(); - if (name) - xbt_dict_set(rdv_points, name, rdv, SIMIX_rdv_free); + if (rdv->name) + xbt_dict_set(rdv_points, rdv->name, rdv, SIMIX_rdv_free); } return rdv; } @@ -60,7 +58,7 @@ smx_rdv_t SIMIX_rdv_create(const char *name) void SIMIX_rdv_destroy(smx_rdv_t rdv) { if (rdv->name) - xbt_dict_remove(rdv_points, rdv->name); + xbt_dict_remove(rdv_points, rdv->name); } void SIMIX_rdv_free(void *data) @@ -315,7 +313,7 @@ smx_action_t SIMIX_comm_irecv(smx_process_t dst_proc, smx_rdv_t rdv, return action; } -void SIMIX_pre_comm_wait(smx_req_t req) +void SIMIX_pre_comm_wait(smx_req_t req, int idx) { smx_action_t action = req->comm_wait.comm; double timeout = req->comm_wait.timeout; @@ -326,7 +324,20 @@ void SIMIX_pre_comm_wait(smx_req_t req) req->issuer->waiting_action = action; if (MC_IS_ENABLED){ - action->state = SIMIX_DONE; + if(idx == 0){ + action->state = SIMIX_DONE; + }else{ + /* If we reached this point, the wait request must have a timeout */ + /* Otherwise it shouldn't be enabled and executed by the MC */ + if(timeout == -1) + THROW_IMPOSSIBLE; + + if(action->comm.src_proc == req->issuer) + action->state = SIMIX_SRC_TIMEOUT; + else + action->state = SIMIX_DST_TIMEOUT; + } + SIMIX_comm_finish(action); return; } @@ -349,8 +360,20 @@ void SIMIX_pre_comm_wait(smx_req_t req) void SIMIX_pre_comm_test(smx_req_t req) { smx_action_t action = req->comm_test.comm; - req->comm_test.result = (action->state != SIMIX_WAITING && action->state != SIMIX_RUNNING); + if(MC_IS_ENABLED){ + req->comm_test.result = action->comm.src_proc && action->comm.dst_proc; + if(req->comm_test.result){ + action->state = SIMIX_DONE; + xbt_fifo_push(action->request_list, req); + SIMIX_comm_finish(action); + }else{ + SIMIX_request_answer(req); + } + return; + } + + req->comm_test.result = (action->state != SIMIX_WAITING && action->state != SIMIX_RUNNING); if (req->comm_test.result) { xbt_fifo_push(action->request_list, req); SIMIX_comm_finish(action); @@ -359,7 +382,7 @@ void SIMIX_pre_comm_test(smx_req_t req) } } -void SIMIX_pre_comm_testany(smx_req_t req, unsigned int idx) +void SIMIX_pre_comm_testany(smx_req_t req, int idx) { unsigned int cursor; smx_action_t action; @@ -367,10 +390,11 @@ void SIMIX_pre_comm_testany(smx_req_t req, unsigned int idx) req->comm_testany.result = -1; if (MC_IS_ENABLED){ - if((int)idx == -1){ + if(idx == -1){ SIMIX_request_answer(req); }else{ action = xbt_dynar_get_as(actions, idx, smx_action_t); + req->comm_testany.result = idx; xbt_fifo_push(action->request_list, req); action->state = SIMIX_DONE; SIMIX_comm_finish(action); @@ -389,7 +413,7 @@ void SIMIX_pre_comm_testany(smx_req_t req, unsigned int idx) SIMIX_request_answer(req); } -void SIMIX_pre_comm_waitany(smx_req_t req, unsigned int idx) +void SIMIX_pre_comm_waitany(smx_req_t req, int idx) { smx_action_t action; unsigned int cursor = 0; @@ -408,7 +432,6 @@ void SIMIX_pre_comm_waitany(smx_req_t req, unsigned int idx) /* Associate this request to the action */ xbt_fifo_push(action->request_list, req); if (action->state != SIMIX_WAITING && action->state != SIMIX_RUNNING){ - req->comm_waitany.result = cursor; SIMIX_comm_finish(action); break; } @@ -481,6 +504,8 @@ void SIMIX_comm_finish(smx_action_t action) return it as the result of the call */ if (req->call == REQ_COMM_WAITANY) { SIMIX_waitany_req_remove_from_actions(req); + if(!MC_IS_ENABLED) + req->comm_waitany.result = xbt_dynar_search(req->comm_waitany.comms, &action); } /* If the action is still in a rendez-vous point then remove from it */ @@ -610,7 +635,9 @@ void SIMIX_comm_cancel(smx_action_t action) SIMIX_rdv_remove(action->comm.rdv, action); action->state = SIMIX_FAILED; } else { - surf_workstation_model->action_cancel(action->comm.surf_comm); + /* When running the MC there are no surf actions */ + if(!MC_IS_ENABLED) + surf_workstation_model->action_cancel(action->comm.surf_comm); } }