From a0432353f714a914f179660603a6ce728070a7ec Mon Sep 17 00:00:00 2001 From: mquinson Date: Fri, 6 Jul 2007 20:21:06 +0000 Subject: [PATCH] Rename some struct fields in private datatype to explicit whether they are smx objects or msg ones git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@3667 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- src/msg/gos.c | 24 ++++++++++++------------ src/msg/host.c | 6 +++--- src/msg/m_process.c | 45 ++++++++++++++++++++++++--------------------- src/msg/private.h | 14 +++++++------- 4 files changed, 46 insertions(+), 43 deletions(-) diff --git a/src/msg/gos.c b/src/msg/gos.c index fcd53b233c..066c700a9f 100644 --- a/src/msg/gos.c +++ b/src/msg/gos.c @@ -82,7 +82,7 @@ static MSG_error_t __MSG_task_get_with_time_out_from_host(m_task_t * task, } else SIMIX_cond_wait(h_simdata->sleeping[channel],h->simdata->mutex); - if(SIMIX_host_get_state(h_simdata->host)==0) + if(SIMIX_host_get_state(h_simdata->s_host)==0) MSG_RETURN(MSG_HOST_FAILURE); first_time = 0; @@ -105,9 +105,9 @@ static MSG_error_t __MSG_task_get_with_time_out_from_host(m_task_t * task, /* Transfer */ t_simdata->using++; /* create SIMIX action to the communication */ - t_simdata->comm = SIMIX_action_communicate(t_simdata->sender->simdata->host->simdata->host, - process->simdata->host->simdata->host,t->name, t_simdata->message_size, - t_simdata->rate); + t_simdata->comm = SIMIX_action_communicate(t_simdata->sender->simdata->m_host->simdata->s_host, + process->simdata->m_host->simdata->s_host,t->name, t_simdata->message_size, + t_simdata->rate); /* if the process is suspend, create the action but stop its execution, it will be restart when the sender process resume */ if (MSG_process_is_suspended(t_simdata->sender)) { DEBUG1("Process sender (%s) suspended", t_simdata->sender->name); @@ -136,7 +136,7 @@ static MSG_error_t __MSG_task_get_with_time_out_from_host(m_task_t * task, SIMIX_action_destroy(t_simdata->comm); t_simdata->comm = NULL; MSG_RETURN(MSG_OK); - } else if (SIMIX_host_get_state(h_simdata->host)==0) { + } else if (SIMIX_host_get_state(h_simdata->s_host)==0) { //t_simdata->comm = NULL; SIMIX_action_destroy(t_simdata->comm); t_simdata->comm = NULL; @@ -325,7 +325,7 @@ MSG_error_t MSG_channel_select_from(m_channel_t channel, double max_duration, } SIMIX_cond_destroy(cond); SIMIX_mutex_unlock(h_simdata->mutex); - if(SIMIX_host_get_state(h_simdata->host)==0) { + if(SIMIX_host_get_state(h_simdata->s_host)==0) { MSG_RETURN(MSG_HOST_FAILURE); } h_simdata->sleeping[channel] = NULL; @@ -424,7 +424,7 @@ MSG_error_t MSG_task_put_with_timeout(m_task_t task, m_host_t dest, "This task is still being used somewhere else. You cannot send it now. Go fix your code!"); task_simdata->comm = NULL; - local_host = ((simdata_process_t) process->simdata)->host; + local_host = ((simdata_process_t) process->simdata)->m_host; remote_host = dest; DEBUG4("Trying to send a task (%g kB) from %s to %s on channel %d", @@ -482,7 +482,7 @@ MSG_error_t MSG_task_put_with_timeout(m_task_t task, m_host_t dest, if(SIMIX_action_get_state(task->simdata->comm) == SURF_ACTION_DONE) { MSG_RETURN(MSG_OK); - } else if (SIMIX_host_get_state(local_host->simdata->host)==0) { + } else if (SIMIX_host_get_state(local_host->simdata->s_host)==0) { MSG_RETURN(MSG_HOST_FAILURE); } else { MSG_RETURN(MSG_TRANSFER_FAILURE); @@ -557,7 +557,7 @@ MSG_error_t MSG_task_execute(m_task_t task) xbt_assert0((!simdata->compute)&&(task->simdata->using==1), "This task is executed somewhere else. Go fix your code!"); - DEBUG1("Computing on %s", MSG_process_self()->simdata->host->name); + DEBUG1("Computing on %s", MSG_process_self()->simdata->m_host->name); simdata->using++; SIMIX_mutex_lock(simdata->mutex); simdata->compute = SIMIX_action_execute(SIMIX_host_self(), task->name, simdata->computation_amount); @@ -649,7 +649,7 @@ m_task_t MSG_parallel_task_create(const char *name, simdata->comm_amount = communication_amount; for(i=0;ihost_list[i] = host_list[i]->simdata->host; + simdata->host_list[i] = host_list[i]->simdata->s_host; return task; @@ -668,7 +668,7 @@ MSG_error_t MSG_parallel_task_execute(m_task_t task) xbt_assert0(simdata->host_nb,"This is not a parallel task. Go to hell."); - DEBUG1("Computing on %s", MSG_process_self()->simdata->host->name); + DEBUG1("Computing on %s", MSG_process_self()->simdata->m_host->name); simdata->using++; SIMIX_mutex_lock(simdata->mutex); simdata->compute = SIMIX_action_parallel_execute(task->name, simdata->host_nb, simdata->host_list, simdata->comp_amount, simdata->comm_amount, 1.0, -1.0); @@ -721,7 +721,7 @@ MSG_error_t MSG_process_sleep(double nb_sec) smx_mutex_t mutex; smx_cond_t cond; /* create action to sleep */ - act_sleep = SIMIX_action_sleep(SIMIX_process_get_host(proc->simdata->smx_process),nb_sec); + act_sleep = SIMIX_action_sleep(SIMIX_process_get_host(proc->simdata->s_process),nb_sec); mutex = SIMIX_mutex_init(); SIMIX_mutex_lock(mutex); diff --git a/src/msg/host.c b/src/msg/host.c index 76b88aaf2e..117b99378b 100644 --- a/src/msg/host.c +++ b/src/msg/host.c @@ -41,7 +41,7 @@ m_host_t __MSG_host_create(smx_host_t workstation, void *data) host->simdata = simdata; host->data = data; - simdata->host = workstation; + simdata->s_host = workstation; simdata->mbox = xbt_new0(xbt_fifo_t, msg_global->max_channel); for (i = 0; i < msg_global->max_channel; i++) @@ -182,7 +182,7 @@ double MSG_get_host_speed(m_host_t h) { xbt_assert0((h!= NULL), "Invalid parameters"); - return(SIMIX_host_get_speed(h->simdata->host)); + return(SIMIX_host_get_speed(h->simdata->s_host)); } /** \ingroup msg_gos_functions @@ -193,5 +193,5 @@ double MSG_get_host_speed(m_host_t h) int MSG_host_is_avail (m_host_t h) { xbt_assert0((h!= NULL), "Invalid parameters"); - return (SIMIX_host_get_state(h->simdata->host)); + return (SIMIX_host_get_state(h->simdata->s_host)); } diff --git a/src/msg/m_process.c b/src/msg/m_process.c index 7e71699fee..c75adcc6b5 100644 --- a/src/msg/m_process.c +++ b/src/msg/m_process.c @@ -103,15 +103,18 @@ m_process_t MSG_process_create_with_arguments(const char *name, /* Simulator Data */ simdata->PID = msg_global->PID++; simdata->waiting_task = NULL; - simdata->host = host; + simdata->m_host = host; simdata->argc = argc; simdata->argv = argv; - simdata->smx_process = SIMIX_process_create(name, (smx_process_code_t)code, (void*)process, host->name, argc, argv, MSG_process_cleanup ); - - if (SIMIX_process_self()) { - simdata->PPID = MSG_process_get_PID(SIMIX_process_self()->data); - } - else simdata->PPID = -1; + simdata->s_process = SIMIX_process_create(name, (smx_process_code_t)code, + (void*)process, host->name, argc, argv, + MSG_process_cleanup ); + + if (SIMIX_process_self()) { + simdata->PPID = MSG_process_get_PID(SIMIX_process_self()->data); + } else { + simdata->PPID = -1; + } simdata->last_errno=MSG_OK; @@ -120,7 +123,7 @@ m_process_t MSG_process_create_with_arguments(const char *name, process->simdata = simdata; process->data = data; - xbt_fifo_unshift(msg_global->process_list, process); + xbt_fifo_unshift(msg_global->process_list, process); return process; } @@ -134,22 +137,22 @@ void MSG_process_kill(m_process_t process) { simdata_process_t p_simdata = process->simdata; - DEBUG3("Killing %s(%d) on %s",process->name, p_simdata->PID, p_simdata->host->name); + DEBUG3("Killing %s(%d) on %s", + process->name, p_simdata->PID, p_simdata->m_host->name); - if(p_simdata->waiting_task) { - DEBUG1("Canceling waiting task %s",p_simdata->waiting_task->name); + if(p_simdata->waiting_task) { + DEBUG1("Canceling waiting task %s",p_simdata->waiting_task->name); if(p_simdata->waiting_task->simdata->compute) { - SIMIX_action_cancel(p_simdata->waiting_task->simdata->compute); - } - else if (p_simdata->waiting_task->simdata->comm) { - SIMIX_action_cancel(p_simdata->waiting_task->simdata->comm); + SIMIX_action_cancel(p_simdata->waiting_task->simdata->compute); + } else if (p_simdata->waiting_task->simdata->comm) { + SIMIX_action_cancel(p_simdata->waiting_task->simdata->comm); } } xbt_fifo_remove(msg_global->process_list,process); - SIMIX_process_kill(process->simdata->smx_process); + SIMIX_process_kill(process->simdata->s_process); - return; + return; } /** \ingroup m_process_management @@ -204,7 +207,7 @@ m_host_t MSG_process_get_host(m_process_t process) { xbt_assert0(((process != NULL) && (process->simdata)), "Invalid parameters"); - return (((simdata_process_t) process->simdata)->host); + return (((simdata_process_t) process->simdata)->m_host); } /** \ingroup m_process_management @@ -318,7 +321,7 @@ MSG_error_t MSG_process_suspend(m_process_t process) xbt_assert0(((process != NULL) && (process->simdata)), "Invalid parameters"); CHECK_HOST(); - SIMIX_process_suspend(process->simdata->smx_process); + SIMIX_process_suspend(process->simdata->s_process); MSG_RETURN(MSG_OK); } @@ -334,7 +337,7 @@ MSG_error_t MSG_process_resume(m_process_t process) xbt_assert0(((process != NULL) && (process->simdata)), "Invalid parameters"); CHECK_HOST(); - SIMIX_process_resume(process->simdata->smx_process); + SIMIX_process_resume(process->simdata->s_process); MSG_RETURN(MSG_OK); } @@ -347,6 +350,6 @@ MSG_error_t MSG_process_resume(m_process_t process) int MSG_process_is_suspended(m_process_t process) { xbt_assert0(((process != NULL) && (process->simdata)), "Invalid parameters"); - return SIMIX_process_is_suspended(process->simdata->smx_process); + return SIMIX_process_is_suspended(process->simdata->s_process); } diff --git a/src/msg/private.h b/src/msg/private.h index e78420d889..80ac9e2bfa 100644 --- a/src/msg/private.h +++ b/src/msg/private.h @@ -24,7 +24,7 @@ /**************** datatypes **********************************/ typedef struct simdata_host { - smx_host_t host; /* SURF modeling */ + smx_host_t s_host; /* SURF modeling */ xbt_fifo_t *mbox; /* array of FIFOs used as a mailboxes */ smx_cond_t *sleeping; /* array of conditions on which the processes sleep if they are waiting for a communication on a channel */ smx_mutex_t mutex; /* mutex to access the host */ @@ -55,13 +55,13 @@ typedef struct simdata_task { /******************************* Process *************************************/ typedef struct simdata_process { - m_host_t host; /* the host on which the process is running */ - smx_process_t smx_process; + m_host_t m_host; /* the host on which the process is running */ + smx_process_t s_process; int PID; /* used for debugging purposes */ int PPID; /* The parent PID */ m_host_t put_host; /* used for debugging purposes */ m_channel_t put_channel; /* used for debugging purposes */ - m_task_t waiting_task; + m_task_t waiting_task; int argc; /* arguments number if any */ char **argv; /* arguments table if any */ MSG_error_t last_errno; /* the last value returned by a MSG_function */ @@ -71,7 +71,7 @@ typedef struct process_arg { const char *name; m_process_code_t code; void *data; - m_host_t host; + m_host_t m_host; int argc; char **argv; double kill_time; @@ -105,8 +105,8 @@ void __MSG_host_destroy(m_host_t host); void __MSG_display_process_status(void); m_process_t __MSG_process_create_with_arguments(const char *name, - m_process_code_t code, void *data, - char * hostname, int argc, char **argv); + m_process_code_t code, void *data, + char * hostname, int argc, char **argv); #endif -- 2.20.1