Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
fullduplex support
[simgrid.git] / src / simix / smx_action.c
index 0f82212..ce3ba8a 100644 (file)
@@ -1,7 +1,5 @@
-/*     $Id$     */
-
-/* Copyright (c) 2007 Arnaud Legrand, Bruno Donnassolo.
-   All rights reserved.                                          */
+/* Copyright (c) 2007, 2009, 2010. The SimGrid Team.
+ * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -50,7 +48,9 @@ smx_action_t SIMIX_action_communicate(smx_host_t sender,
   /* initialize them */
   act->name = xbt_strdup(name);
   act->source = sender;
-
+#ifdef HAVE_TRACING
+  act->category = NULL;
+#endif
 
   act->surf_action =
     surf_workstation_model->extension.workstation.communicate(sender->host,
@@ -90,6 +90,9 @@ smx_action_t SIMIX_action_execute(smx_host_t host, const char *name,
   /* initialize them */
   act->source = host;
   act->name = xbt_strdup(name);
+#ifdef HAVE_TRACING
+  act->category = NULL;
+#endif
 
   /* set communication */
   act->surf_action =
@@ -98,6 +101,9 @@ smx_action_t SIMIX_action_execute(smx_host_t host, const char *name,
   surf_workstation_model->action_data_set(act->surf_action, act);
 
   DEBUG1("Create execute action %p", act);
+#ifdef HAVE_TRACING
+  TRACE_smx_action_execute (act);
+#endif
   return act;
 }
 
@@ -131,6 +137,9 @@ smx_action_t SIMIX_action_sleep(smx_host_t host, double duration)
   /* initialize them */
   act->source = host;
   act->name = xbt_strdup(name);
+#ifdef HAVE_TRACING
+  act->category = NULL;
+#endif
 
   act->surf_action =
     surf_workstation_model->extension.workstation.sleep(host->host, duration);
@@ -147,7 +156,7 @@ smx_action_t SIMIX_action_sleep(smx_host_t host, double duration)
  *     This functions stops the execution of an action. It calls a surf functions.
  *     \param action The SIMIX action
  */
-void SIMIX_action_cancel(smx_action_t action)
+XBT_INLINE void SIMIX_action_cancel(smx_action_t action)
 {
   xbt_assert0((action != NULL), "Invalid parameter");
 
@@ -165,7 +174,7 @@ void SIMIX_action_cancel(smx_action_t action)
  *     \param action The SIMIX action
  *     \param priority The new priority
  */
-void SIMIX_action_set_priority(smx_action_t action, double priority)
+XBT_INLINE void SIMIX_action_set_priority(smx_action_t action, double priority)
 {
   xbt_assert0((action != NULL), "Invalid parameter");
 
@@ -173,6 +182,36 @@ void SIMIX_action_set_priority(smx_action_t action, double priority)
   return;
 }
 
+/**
+ *     \brief Resumes the execution of an action.
+ *
+ *  This functions restarts the execution of an action. It just calls the right SURF function.
+ *  \param action The SIMIX action
+ *  \param priority The new priority
+ */
+XBT_INLINE void SIMIX_action_resume(smx_action_t action)
+{
+  xbt_assert0((action != NULL), "Invalid parameter");
+
+  surf_workstation_model->resume(action->surf_action);
+  return;
+}
+
+/**
+ *  \brief Suspends the execution of an action.
+ *
+ *  This functions suspends the execution of an action. It just calls the right SURF function.
+ *  \param action The SIMIX action
+ *  \param priority The new priority
+ */
+XBT_INLINE void SIMIX_action_suspend(smx_action_t action)
+{
+  xbt_assert0((action != NULL), "Invalid parameter");
+
+  surf_workstation_model->suspend(action->surf_action);
+  return;
+}
+
 /**
  *     \brief Destroys an action
  *
@@ -205,7 +244,9 @@ int SIMIX_action_destroy(smx_action_t action)
 
   if (action->surf_action)
     action->surf_action->model_type->action_unref(action->surf_action);
-
+#ifdef HAVE_TRACING
+  TRACE_smx_action_destroy (action);
+#endif
   xbt_free(action);
   return 1;
 }
@@ -215,7 +256,7 @@ int SIMIX_action_destroy(smx_action_t action)
  *
  *     \param action The SIMIX action
  */
-void SIMIX_action_use(smx_action_t action)
+XBT_INLINE void SIMIX_action_use(smx_action_t action)
 {
   XBT_IN3("(%p:'%s',%d)", action, action->name, action->refcount);
   xbt_assert0((action != NULL), "Invalid parameter");
@@ -230,7 +271,7 @@ void SIMIX_action_use(smx_action_t action)
  *
  *     \param action The SIMIX action
  */
-void SIMIX_action_release(smx_action_t action)
+XBT_INLINE void SIMIX_action_release(smx_action_t action)
 {
   xbt_assert0((action != NULL), "Invalid parameter");
 
@@ -303,7 +344,7 @@ void SIMIX_unregister_action_to_condition(smx_action_t action,
  *
  *  When the action terminates, the semaphore gets signaled automatically.
  */
-void SIMIX_register_action_to_semaphore(smx_action_t action, smx_sem_t sem) {
+XBT_INLINE void SIMIX_register_action_to_semaphore(smx_action_t action, smx_sem_t sem) {
 
   DEBUG2("Register action %p to semaphore %p (and otherwise)", action, sem);
   xbt_fifo_push(sem->actions, action);
@@ -314,7 +355,7 @@ void SIMIX_register_action_to_semaphore(smx_action_t action, smx_sem_t sem) {
  *
  *  Destroys the "links" from the semaphore to this action.
  */
-void SIMIX_unregister_action_to_semaphore(smx_action_t action,
+XBT_INLINE void SIMIX_unregister_action_to_semaphore(smx_action_t action,
                                           smx_sem_t sem)
 {
   xbt_fifo_remove_all(sem->actions, action);
@@ -327,12 +368,18 @@ void SIMIX_unregister_action_to_semaphore(smx_action_t action,
  *     \param action The SIMIX action
  *     \return Remains cost
  */
-double SIMIX_action_get_remains(smx_action_t action)
+XBT_INLINE double SIMIX_action_get_remains(smx_action_t action)
 {
   xbt_assert0((action != NULL), "Invalid parameter");
   return surf_workstation_model->get_remains(action->surf_action);
 }
 
+XBT_INLINE int SIMIX_action_is_latency_bounded(smx_action_t action)
+{
+  xbt_assert0((action != NULL), "Invalid parameter");
+  return surf_workstation_model->get_latency_limited(action->surf_action);
+}
+
 smx_action_t SIMIX_action_parallel_execute(char *name, int host_nb,
                                            smx_host_t * host_list,
                                            double *computation_amount,
@@ -350,6 +397,9 @@ smx_action_t SIMIX_action_parallel_execute(char *name, int host_nb,
 
   /* initialize them */
   act->name = xbt_strdup(name);
+#ifdef HAVE_TRACING
+  act->category = NULL;
+#endif
 
   /* set action */
 
@@ -367,7 +417,7 @@ smx_action_t SIMIX_action_parallel_execute(char *name, int host_nb,
   return act;
 }
 
-e_surf_action_state_t SIMIX_action_get_state(smx_action_t action)
+XBT_INLINE e_surf_action_state_t SIMIX_action_get_state(smx_action_t action)
 {
   xbt_assert0((action != NULL), "Invalid parameter");
   return surf_workstation_model->action_state_get(action->surf_action);
@@ -393,13 +443,13 @@ void __SIMIX_action_display_conditions(smx_action_t action)
     DEBUG1("\t %p", cond);
 }
 
-char *SIMIX_action_get_name(smx_action_t action)
+XBT_INLINE char *SIMIX_action_get_name(smx_action_t action)
 {
   xbt_assert0((action != NULL), "Invalid parameter");
   return action->name;
 }
 /** @brief Change the name of the action. Warning, the string you provide is not strdup()ed */
-void SIMIX_action_set_name(smx_action_t action,char *name)
+XBT_INLINE void SIMIX_action_set_name(smx_action_t action,char *name)
 {
   xbt_free(action->name);
   action->name = name;