X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/8e5b8588203716306cdbf99953d4f8202d686134..803db5b144024a4e2fd78b35744ebc1dba549a21:/src/msg/m_process.c
diff --git a/src/msg/m_process.c b/src/msg/m_process.c
index cf354393b4..06f85c3810 100644
--- a/src/msg/m_process.c
+++ b/src/msg/m_process.c
@@ -8,13 +8,14 @@
#include "private.h"
#include "xbt/sysdep.h"
#include "xbt/log.h"
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(m_process, msg,
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_process, msg,
"Logging specific to MSG (process)");
/** \defgroup m_process_management Management Functions of Agents
* \brief This section describes the agent structure of MSG
* (#m_process_t) and the functions for managing it.
- *
+ * \htmlonly \endhtmlonly
+ *
* We need to simulate many independent scheduling decisions, so
* the concept of process is at the heart of the
* simulator. A process may be defined as a code, with
@@ -113,15 +114,17 @@ m_process_t MSG_process_create_with_arguments(const char *name,
process->simdata = simdata;
process->data = data;
- xbt_fifo_push(host->simdata->process_list, process);
+ xbt_fifo_unshift(host->simdata->process_list, process);
- /* /////////////// FIX du current_process !!! ////////////// */
+ /* *************** FIX du current_process !!! *************** */
self = msg_global->current_process;
xbt_context_start(process->simdata->context);
msg_global->current_process = self;
- xbt_fifo_push(msg_global->process_list, process);
- xbt_fifo_push(msg_global->process_to_run, process);
+ xbt_fifo_unshift(msg_global->process_list, process);
+ DEBUG2("Inserting %s(%s) in the to_run list",process->name,
+ host->name);
+ xbt_fifo_unshift(msg_global->process_to_run, process);
PAJE_PROCESS_NEW(process);
@@ -141,8 +144,8 @@ void MSG_process_kill(m_process_t process)
int _cursor;
m_process_t proc = NULL;
-/* fprintf(stderr,"Killing %s(%d) on %s.\n",process->name, */
-/* p_simdata->PID,p_simdata->host->name); */
+ DEBUG3("Killing %s(%d) on %s",process->name, p_simdata->PID,
+ p_simdata->host->name);
for (i=0; imax_channel; i++) {
if (h_simdata->sleeping[i] == process) {
@@ -150,34 +153,38 @@ void MSG_process_kill(m_process_t process)
break;
}
}
- if (i==msg_global->max_channel) {
- if(p_simdata->waiting_task) {
- xbt_dynar_foreach(p_simdata->waiting_task->simdata->sleeping,_cursor,proc) {
- if(proc==process)
- xbt_dynar_remove_at(p_simdata->waiting_task->simdata->sleeping,_cursor,&proc);
- }
- if(p_simdata->waiting_task->simdata->compute)
- surf_workstation_resource->common_public->
- action_free(p_simdata->waiting_task->simdata->compute);
- else if (p_simdata->waiting_task->simdata->comm) {
- surf_workstation_resource->common_public->
- action_change_state(p_simdata->waiting_task->simdata->comm,SURF_ACTION_FAILED);
- surf_workstation_resource->common_public->
- action_free(p_simdata->waiting_task->simdata->comm);
- } else
- CRITICAL0("UNKNOWN STATUS. Please report this bug.");
- } else { /* Must be trying to put a task somewhere */
- if(process==MSG_process_self()) {
- return;
- } else {
- CRITICAL0("UNKNOWN STATUS. Please report this bug.");
- }
+
+ if(p_simdata->waiting_task) {
+ xbt_dynar_foreach(p_simdata->waiting_task->simdata->sleeping,_cursor,proc) {
+ if(proc==process)
+ xbt_dynar_remove_at(p_simdata->waiting_task->simdata->sleeping,_cursor,&proc);
+ }
+ if(p_simdata->waiting_task->simdata->compute)
+ surf_workstation_resource->common_public->
+ action_free(p_simdata->waiting_task->simdata->compute);
+ else if (p_simdata->waiting_task->simdata->comm) {
+ surf_workstation_resource->common_public->
+ action_change_state(p_simdata->waiting_task->simdata->comm,SURF_ACTION_FAILED);
+ surf_workstation_resource->common_public->
+ action_free(p_simdata->waiting_task->simdata->comm);
+ } else {
+ xbt_die("UNKNOWN STATUS. Please report this bug.");
}
}
+ if ((i==msg_global->max_channel) && (process!=MSG_process_self()) &&
+ (!p_simdata->waiting_task)) {
+ xbt_die("UNKNOWN STATUS. Please report this bug.");
+ }
+
xbt_fifo_remove(msg_global->process_to_run,process);
xbt_fifo_remove(msg_global->process_list,process);
xbt_context_free(process->simdata->context);
+
+ if(process==MSG_process_self()) {
+ /* I just killed myself */
+ xbt_context_yield();
+ }
}
/** \ingroup m_process_management
@@ -198,7 +205,7 @@ MSG_error_t MSG_process_change_host(m_process_t process, m_host_t host)
xbt_fifo_remove(simdata->host->simdata->process_list,process);
simdata->host = host;
- xbt_fifo_push(host->simdata->process_list,process);
+ xbt_fifo_unshift(host->simdata->process_list,process);
return MSG_OK;
}
@@ -351,7 +358,7 @@ MSG_error_t MSG_process_suspend(m_process_t process)
xbt_assert0(((process) && (process->simdata)), "Invalid parameters");
- PAJE_PROCESS_PUSH_STATE(process,"S");
+ PAJE_PROCESS_PUSH_STATE(process,"S",NULL);
if(process!=MSG_process_self()) {
simdata = process->simdata;
@@ -456,21 +463,19 @@ int MSG_process_is_suspended(m_process_t process)
return (process->simdata->suspended);
}
-static char blocked_name[512];
-
-int __MSG_process_block(double max_duration)
+int __MSG_process_block(double max_duration, const char *info)
{
m_process_t process = MSG_process_self();
-
m_task_t dummy = MSG_TASK_UNINITIALIZED;
- snprintf(blocked_name,512,"blocked (%s:%s)",process->name,
- process->simdata->host->name);
+ char blocked_name[512];
+ snprintf(blocked_name,512,"blocked [%s] (%s:%s)",
+ info, process->name, process->simdata->host->name);
XBT_IN1(": max_duration=%g",max_duration);
dummy = MSG_task_create(blocked_name, 0.0, 0, NULL);
- PAJE_PROCESS_PUSH_STATE(process,"B");
+ PAJE_PROCESS_PUSH_STATE(process,"B",NULL);
process->simdata->blocked=1;
__MSG_task_execute(process,dummy);