X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/710e7c0ce3fce936637636f544019e89e8ef023d..012e8850b96760b97bee7f40ce87b4093866153e:/src/msg/gos.c diff --git a/src/msg/gos.c b/src/msg/gos.c index d167c7a4e6..fd042a49aa 100644 --- a/src/msg/gos.c +++ b/src/msg/gos.c @@ -77,7 +77,11 @@ MSG_error_t MSG_task_get(m_task_t * task, t_simdata->using++; t_simdata->comm = surf_workstation_resource->extension_public-> communicate(MSG_process_get_host(t_simdata->sender)->simdata->host, - h, t_simdata->message_size); + h->simdata->host, t_simdata->message_size); + surf_workstation_resource->common_public->action_set_data(t_simdata->comm,t); + + if(MSG_process_isSuspended(t_simdata->sender)) + MSG_process_resume(t_simdata->sender); do { __MSG_task_wait_event(process, t); @@ -111,6 +115,33 @@ int MSG_task_Iprobe(m_channel_t channel) return(xbt_fifo_getFirstItem(h_simdata->mbox[channel])!=NULL); } +/** \ingroup msg_gos_functions + * \brief Test whether there is a pending communication on a channel, and who sent it. + * + * It takes one parameter. + * \param channel the channel on which the agent should be + listening. This value has to be >=0 and < than the maximal + number of channels fixed with MSG_set_channel_number(). + * \return -1 if there is no pending communication and the PID of the process who sent it otherwise + */ +int MSG_task_probe_from(m_channel_t channel) +{ + m_host_t h = NULL; + simdata_host_t h_simdata = NULL; + xbt_fifo_item_t item; + m_task_t t; + + CHECK_HOST(); + h = MSG_host_self(); + h_simdata = h->simdata; + + 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) + return -1; + + return MSG_process_get_PID(((simdata_task_t)t->simdata)->sender); +} + /** \ingroup msg_gos_functions * \brief Put a task on a channel of an host and waits for the end of the * transmission. @@ -147,7 +178,8 @@ MSG_error_t MSG_task_put(m_task_t task, task_simdata = task->simdata; task_simdata->sender = process; - + xbt_assert0(task_simdata->using==1,"Gargl!"); + task_simdata->comm = NULL; local_host = ((simdata_process_t) process->simdata)->host; remote_host = dest; @@ -157,9 +189,15 @@ MSG_error_t MSG_task_put(m_task_t task, if(remote_host->simdata->sleeping[channel]) MSG_process_resume(remote_host->simdata->sleeping[channel]); - else - MSG_process_suspend(process); - + else { + process->simdata->put_host = dest; + process->simdata->put_channel = channel; + while(!(task_simdata->comm)) + MSG_process_suspend(process); + process->simdata->put_host = NULL; + process->simdata->put_channel = -1; + } + do { __MSG_task_wait_event(process, task); state=surf_workstation_resource->common_public->action_get_state(task_simdata->comm); @@ -203,6 +241,7 @@ void __MSG_task_execute(m_process_t process, m_task_t task) simdata->compute = surf_workstation_resource->extension_public-> execute(MSG_process_get_host(process)->simdata->host, simdata->computation_amount); + surf_workstation_resource->common_public->action_set_data(simdata->compute,task); } MSG_error_t __MSG_wait_for_computation(m_process_t process, m_task_t task) @@ -247,6 +286,7 @@ MSG_error_t MSG_process_sleep(long double nb_sec) simdata->compute = surf_workstation_resource->extension_public-> sleep(MSG_process_get_host(process)->simdata->host, simdata->computation_amount); + surf_workstation_resource->common_public->action_set_data(simdata->compute,dummy); simdata->using++;