X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/f537f6705eaf9d1d99186860f2da468a9d755417..409cad633c6b5032649e7a54f6311e41c6178899:/src/msg/gos.c diff --git a/src/msg/gos.c b/src/msg/gos.c index 17f0326181..9dcfb54cd9 100644 --- a/src/msg/gos.c +++ b/src/msg/gos.c @@ -11,6 +11,11 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(gos, msg, "Logging specific to MSG (gos)"); +/** \defgroup msg_gos_functions MSG Operating System Functions + * \brief This section describes the functions that can be used + * by an agent for handling some task. + */ + /** \ingroup msg_gos_functions * \brief This function is now deprecated and useless. Please stop using it. */ @@ -56,7 +61,10 @@ MSG_error_t MSG_task_get(m_task_t * task, /* Get the task */ h = MSG_host_self(); h_simdata = h->simdata; - while ((t = xbt_fifo_pop(h_simdata->mbox[channel])) == NULL) { + + DEBUG2("Waiting for a task on channel %d (%s)", channel,h->name); + + while ((t = xbt_fifo_shift(h_simdata->mbox[channel])) == NULL) { xbt_assert2(!(h_simdata->sleeping[channel]), "A process (%s(%d)) is already blocked on this channel", h_simdata->sleeping[channel]->name, @@ -86,7 +94,7 @@ MSG_error_t MSG_task_get(m_task_t * task, if(__MSG_process_isBlocked(t_simdata->sender)) __MSG_process_unblock(t_simdata->sender); - PAJE_PROCESS_STATE(process,"C"); + PAJE_PROCESS_PUSH_STATE(process,"C"); do { __MSG_task_wait_event(process, t); @@ -98,6 +106,7 @@ MSG_error_t MSG_task_get(m_task_t * task, xbt_context_yield(); } + PAJE_PROCESS_POP_STATE(process); PAJE_COMM_STOP(process,t,channel); if(state == SURF_ACTION_DONE) MSG_RETURN(MSG_OK); @@ -121,6 +130,7 @@ int MSG_task_Iprobe(m_channel_t channel) m_host_t h = NULL; simdata_host_t h_simdata = NULL; + DEBUG2("Probing on channel %d (%s)", channel,h->name); CHECK_HOST(); h = MSG_host_self(); h_simdata = h->simdata; @@ -146,12 +156,14 @@ int MSG_task_probe_from(m_channel_t channel) CHECK_HOST(); h = MSG_host_self(); h_simdata = h->simdata; + + DEBUG2("Probing on channel %d (%s)", channel,h->name); - item = xbt_fifo_getFirstItem(((simdata_host_t)h->simdata)->mbox[channel]); - if (!item || !(t = xbt_fifo_get_item_content(item)) || (simdata_task_t)t->simdata) + item = xbt_fifo_getFirstItem(h->simdata->mbox[channel]); + if (!item || !(t = xbt_fifo_get_item_content(item))) return -1; - return MSG_process_get_PID(((simdata_task_t)t->simdata)->sender); + return MSG_process_get_PID(t->simdata->sender); } /** \ingroup msg_gos_functions @@ -196,6 +208,9 @@ MSG_error_t MSG_task_put(m_task_t task, local_host = ((simdata_process_t) process->simdata)->host; remote_host = dest; + DEBUG4("Trying to send a task (%lg Mb) from %s to %s on channel %d", + task->simdata->message_size,local_host->name, remote_host->name, channel); + xbt_fifo_push(((simdata_host_t) remote_host->simdata)-> mbox[channel], task); @@ -203,16 +218,16 @@ MSG_error_t MSG_task_put(m_task_t task, if(remote_host->simdata->sleeping[channel]) __MSG_process_unblock(remote_host->simdata->sleeping[channel]); -/* else { */ + process->simdata->put_host = dest; process->simdata->put_channel = channel; while(!(task_simdata->comm)) __MSG_process_block(); process->simdata->put_host = NULL; process->simdata->put_channel = -1; -/* } */ - PAJE_PROCESS_STATE(process,"C"); + + PAJE_PROCESS_PUSH_STATE(process,"C"); state=surf_workstation_resource->common_public->action_get_state(task_simdata->comm); while (state==SURF_ACTION_RUNNING) { @@ -222,6 +237,8 @@ MSG_error_t MSG_task_put(m_task_t task, MSG_task_destroy(task); + PAJE_PROCESS_POP_STATE(process); + if(state == SURF_ACTION_DONE) MSG_RETURN(MSG_OK); else if(surf_workstation_resource->extension_public->get_state(local_host->simdata->host) == SURF_CPU_OFF) @@ -237,7 +254,7 @@ MSG_error_t MSG_task_put(m_task_t task, */ MSG_error_t MSG_task_put_bounded(m_task_t task, m_host_t dest, m_channel_t channel, - long double max_rate) + double max_rate) { task->simdata->rate=max_rate; return(MSG_task_put(task, dest, channel)); @@ -257,10 +274,16 @@ MSG_error_t MSG_task_put_bounded(m_task_t task, MSG_error_t MSG_task_execute(m_task_t task) { m_process_t process = MSG_process_self(); + MSG_error_t res; + + DEBUG1("Computing on %s", process->simdata->host->name); __MSG_task_execute(process, task); - PAJE_PROCESS_STATE(process,"E"); - return __MSG_wait_for_computation(process,task); + + PAJE_PROCESS_PUSH_STATE(process,"E"); + res = __MSG_wait_for_computation(process,task); + PAJE_PROCESS_POP_STATE(process); + return res; } void __MSG_task_execute(m_process_t process, m_task_t task) @@ -305,7 +328,7 @@ MSG_error_t __MSG_wait_for_computation(m_process_t process, m_task_t task) * * \param nb_sec a number of second */ -MSG_error_t MSG_process_sleep(long double nb_sec) +MSG_error_t MSG_process_sleep(double nb_sec) { e_surf_action_state_t state = SURF_ACTION_NOT_IN_THE_SYSTEM; m_process_t process = MSG_process_self();