Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
sanitize the process_create simcall
[simgrid.git] / src / simix / libsmx.c
index 17ff1ba..6287ac4 100644 (file)
 
 #include "mc/mc_replay.h"
 #include "smx_private.h"
-#include "mc/mc_interface.h"
+#include "mc/mc_forward.h"
 #include "xbt/ex.h"
 #include <math.h>         /* isfinite() */
+#include "mc/mc.h"
 
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix);
 
 #include "popping_bodies.c"
 
-/**
- * \ingroup simix_host_management
- * \brief Returns a host given its name.
- *
- * \param name The name of the host to get
- * \return The corresponding host
- */
-smx_host_t simcall_host_get_by_name(const char *name)
-{
-  return simcall_BODY_host_get_by_name(name);
-}
-
 /**
  * \ingroup simix_host_management
  * \brief Returns the name of a host.
@@ -39,7 +28,7 @@ smx_host_t simcall_host_get_by_name(const char *name)
  * \param host A SIMIX host
  * \return The name of this host
  */
-const char* simcall_host_get_name(smx_host_t host)
+const char* simcall_host_get_name(sg_host_t host)
 {
   return simcall_BODY_host_get_name(host);
 }
@@ -50,7 +39,7 @@ const char* simcall_host_get_name(smx_host_t host)
  *
  * \param host A SIMIX host
  */
-void simcall_host_on(smx_host_t host)
+void simcall_host_on(sg_host_t host)
 {
   simcall_BODY_host_on(host);
 }
@@ -61,7 +50,7 @@ void simcall_host_on(smx_host_t host)
  *
  * \param host A SIMIX host
  */
-void simcall_host_off(smx_host_t host)
+void simcall_host_off(sg_host_t host)
 {
   simcall_BODY_host_off(host);
 }
@@ -73,7 +62,7 @@ void simcall_host_off(smx_host_t host)
  * \param host A host
  * \return The properties of this host
  */
-xbt_dict_t simcall_host_get_properties(smx_host_t host)
+xbt_dict_t simcall_host_get_properties(sg_host_t host)
 {
   return simcall_BODY_host_get_properties(host);
 }
@@ -99,7 +88,7 @@ xbt_dict_t simcall_asr_get_properties(const char *name)
  * \param host A SIMIX host
  * \return The speed of this host (in Mflop/s)
  */
-double simcall_host_get_speed(smx_host_t host)
+double simcall_host_get_speed(sg_host_t host)
 {
   return simcall_BODY_host_get_speed(host);
 }
@@ -111,7 +100,7 @@ double simcall_host_get_speed(smx_host_t host)
  * \param host A SIMIX host
  * \return The number of core
  */
-int simcall_host_get_core(smx_host_t host)
+int simcall_host_get_core(sg_host_t host)
 {
   return simcall_BODY_host_get_core(host);
 }
@@ -123,7 +112,7 @@ int simcall_host_get_core(smx_host_t host)
  * \param host A SIMIX host
  * \return the swag of attached processes
  */
-xbt_swag_t simcall_host_get_process_list(smx_host_t host)
+xbt_swag_t simcall_host_get_process_list(sg_host_t host)
 {
   return simcall_BODY_host_get_process_list(host);
 }
@@ -135,7 +124,7 @@ xbt_swag_t simcall_host_get_process_list(smx_host_t host)
  *
  * \return Speed currently available (in Mflop/s)
  */
-double simcall_host_get_available_speed(smx_host_t host)
+double simcall_host_get_available_speed(sg_host_t host)
 {
   return simcall_BODY_host_get_available_speed(host);
 }
@@ -148,7 +137,7 @@ double simcall_host_get_available_speed(smx_host_t host)
  * \param host A SIMIX host
  * \return 1 if the host is available, 0 otherwise
  */
-int simcall_host_get_state(smx_host_t host)
+int simcall_host_get_state(sg_host_t host)
 {
   return simcall_BODY_host_get_state(host);
 }
@@ -160,7 +149,7 @@ int simcall_host_get_state(smx_host_t host)
  * \param host A SIMIX host
  * \return the current power peak value (double)
  */
-double simcall_host_get_current_power_peak(smx_host_t host)
+double simcall_host_get_current_power_peak(sg_host_t host)
 {
   return simcall_BODY_host_get_current_power_peak(host);
 }
@@ -173,7 +162,7 @@ double simcall_host_get_current_power_peak(smx_host_t host)
  * \param pstate_index pstate to test
  * \return the current power peak value (double) for pstate_index
  */
-double simcall_host_get_power_peak_at(smx_host_t host, int pstate_index)
+double simcall_host_get_power_peak_at(sg_host_t host, int pstate_index)
 {
   return simcall_BODY_host_get_power_peak_at(host, pstate_index);
 }
@@ -185,21 +174,31 @@ double simcall_host_get_power_peak_at(smx_host_t host, int pstate_index)
  * \param host A SIMIX host
  * \return the number of power states
  */
-int simcall_host_get_nb_pstates(smx_host_t host)
+int simcall_host_get_nb_pstates(sg_host_t host)
 {
   return simcall_BODY_host_get_nb_pstates(host);
 }
 
 /**
  * \ingroup simix_host_management
- * \brief Sets a new power peak for a host.
+ * \brief Sets the pstate at which the host should run
  *
  * \param host A SIMIX host
  * \param pstate_index The pstate to which the CPU power will be set
  */
-void simcall_host_set_power_peak_at(smx_host_t host, int pstate_index)
+void simcall_host_set_pstate(sg_host_t host, int pstate_index)
+{
+       simcall_BODY_host_set_pstate(host, pstate_index);
+}
+/**
+ * \ingroup simix_host_management
+ * \brief Gets the pstate at which that host currently runs.
+ *
+ * \param host A SIMIX host
+ */
+int simcall_host_get_pstate(sg_host_t host)
 {
-       simcall_BODY_host_set_power_peak_at(host, pstate_index);
+       return simcall_BODY_host_get_pstate(host);
 }
 
 /**
@@ -209,10 +208,23 @@ void simcall_host_set_power_peak_at(smx_host_t host, int pstate_index)
  * \param host A SIMIX host
  * \return the energy consumed by the host (double)
  */
-double simcall_host_get_consumed_energy(smx_host_t host)
+double simcall_host_get_consumed_energy(sg_host_t host)
 {
   return simcall_BODY_host_get_consumed_energy(host);
 }
+/** \ingroup simix_host_management
+ * \brief Returns the amount of watt dissipated at the given pstate when the host is idling
+ */
+double simcall_host_get_wattmin_at(msg_host_t host, int pstate){
+       return simcall_BODY_host_get_wattmin_at(host, pstate);
+}
+/** \ingroup simix_host_management
+ * \brief Returns the amount of watt dissipated at the given pstate when the host burns CPU at 100%
+ */
+double simcall_host_get_wattmax_at(msg_host_t host, int pstate){
+       return simcall_BODY_host_get_wattmax_at(host, pstate);
+}
+
 
 
 /**
@@ -230,7 +242,7 @@ double simcall_host_get_consumed_energy(smx_host_t host)
  * \param affinity_mask
  * \return A new SIMIX execution synchronization
  */
-smx_synchro_t simcall_host_execute(const char *name, smx_host_t host,
+smx_synchro_t simcall_host_execute(const char *name, sg_host_t host,
                                     double flops_amount,
                                     double priority, double bound, unsigned long affinity_mask)
 {
@@ -258,7 +270,7 @@ smx_synchro_t simcall_host_execute(const char *name, smx_host_t host,
  */
 smx_synchro_t simcall_host_parallel_execute(const char *name,
                                          int host_nb,
-                                         smx_host_t *host_list,
+                                         sg_host_t *host_list,
                                          double *flops_amount,
                                          double *bytes_amount,
                                          double amount,
@@ -370,7 +382,7 @@ void simcall_host_execution_set_bound(smx_synchro_t execution, double bound)
  * \param host Host
  * \param mask Affinity mask
  */
-void simcall_host_execution_set_affinity(smx_synchro_t execution, smx_host_t host, unsigned long mask)
+void simcall_host_execution_set_affinity(smx_synchro_t execution, sg_host_t host, unsigned long mask)
 {
   simcall_BODY_host_execution_set_affinity(execution, host, mask);
 }
@@ -396,7 +408,7 @@ e_smx_state_t simcall_host_execution_wait(smx_synchro_t execution)
  *
  * \return The host object of the VM
  */
-void* simcall_vm_create(const char *name, smx_host_t phys_host){
+void* simcall_vm_create(const char *name, sg_host_t phys_host){
   return simcall_BODY_vm_create(name, phys_host);
 }
 
@@ -406,7 +418,7 @@ void* simcall_vm_create(const char *name, smx_host_t phys_host){
  *
  * \param vm VM
  */
-void simcall_vm_start(smx_host_t vm)
+void simcall_vm_start(sg_host_t vm)
 {
   simcall_BODY_vm_start(vm);
 }
@@ -418,7 +430,7 @@ void simcall_vm_start(smx_host_t vm)
  * \param vm VM
  * \return The state of the VM
  */
-int simcall_vm_get_state(smx_host_t vm)
+int simcall_vm_get_state(sg_host_t vm)
 {
   return simcall_BODY_vm_get_state(vm);
 }
@@ -430,27 +442,27 @@ int simcall_vm_get_state(smx_host_t vm)
  * \param vm VM
  * \return The name of the physical host
  */
-void *simcall_vm_get_pm(smx_host_t vm)
+void *simcall_vm_get_pm(sg_host_t vm)
 {
   return simcall_BODY_vm_get_pm(vm);
 }
 
-void simcall_vm_set_bound(smx_host_t vm, double bound)
+void simcall_vm_set_bound(sg_host_t vm, double bound)
 {
   simcall_BODY_vm_set_bound(vm, bound);
 }
 
-void simcall_vm_set_affinity(smx_host_t vm, smx_host_t pm, unsigned long mask)
+void simcall_vm_set_affinity(sg_host_t vm, sg_host_t pm, unsigned long mask)
 {
   simcall_BODY_vm_set_affinity(vm, pm, mask);
 }
 
-void simcall_host_get_params(smx_host_t vm, ws_params_t params)
+void simcall_host_get_params(sg_host_t vm, vm_params_t params)
 {
   simcall_BODY_host_get_params(vm, params);
 }
 
-void simcall_host_set_params(smx_host_t vm, ws_params_t params)
+void simcall_host_set_params(sg_host_t vm, vm_params_t params)
 {
   simcall_BODY_host_set_params(vm, params);
 }
@@ -462,7 +474,7 @@ void simcall_host_set_params(smx_host_t vm, ws_params_t params)
  * \param vm VM
  * \param host Destination physical host
  */
-void simcall_vm_migrate(smx_host_t vm, smx_host_t host)
+void simcall_vm_migrate(sg_host_t vm, sg_host_t host)
 {
   simcall_BODY_vm_migrate(vm, host);
 }
@@ -473,7 +485,7 @@ void simcall_vm_migrate(smx_host_t vm, smx_host_t host)
  *
  * \param vm VM
  */
-void simcall_vm_suspend(smx_host_t vm)
+void simcall_vm_suspend(sg_host_t vm)
 {
   simcall_BODY_vm_suspend(vm);
 }
@@ -484,7 +496,7 @@ void simcall_vm_suspend(smx_host_t vm)
  *
  * \param vm VM
  */
-void simcall_vm_resume(smx_host_t vm)
+void simcall_vm_resume(sg_host_t vm)
 {
   simcall_BODY_vm_resume(vm);
 }
@@ -495,7 +507,7 @@ void simcall_vm_resume(smx_host_t vm)
  *
  * \param vm VM
  */
-void simcall_vm_save(smx_host_t vm)
+void simcall_vm_save(sg_host_t vm)
 {
   simcall_BODY_vm_save(vm);
 }
@@ -506,7 +518,7 @@ void simcall_vm_save(smx_host_t vm)
  *
  * \param vm VM
  */
-void simcall_vm_restore(smx_host_t vm)
+void simcall_vm_restore(sg_host_t vm)
 {
   simcall_BODY_vm_restore(vm);
 }
@@ -517,7 +529,7 @@ void simcall_vm_restore(smx_host_t vm)
  *
  * \param vm VM
  */
-void simcall_vm_shutdown(smx_host_t vm)
+void simcall_vm_shutdown(sg_host_t vm)
 {
   simcall_BODY_vm_shutdown(vm);
 }
@@ -528,11 +540,29 @@ void simcall_vm_shutdown(smx_host_t vm)
  *
  * \param vm VM
  */
-void simcall_vm_destroy(smx_host_t vm)
+void simcall_vm_destroy(sg_host_t vm)
 {
   simcall_BODY_vm_destroy(vm);
 }
 
+/**
+ * \ingroup simix_vm_management
+ * \brief Encompassing simcall to prevent the removal of the src or the dst node at the end of a VM migration
+ *  The simcall actually invokes the following calls: 
+ *     simcall_vm_set_affinity(vm, src_pm, 0); 
+ *     simcall_vm_migrate(vm, dst_pm); 
+ *     simcall_vm_resume(vm);
+ *
+ * It is called at the end of the migration_rx_fun function from msg/msg_vm.c
+ *
+ * \param vm VM to migrate
+ * \param src_pm  Source physical host
+ * \param dst_pmt Destination physical host
+ */
+void simcall_vm_migratefrom_resumeto(sg_host_t vm, sg_host_t src_pm, sg_host_t dst_pm)
+{
+  simcall_BODY_vm_migratefrom_resumeto(vm, src_pm, dst_pm);
+}
 
 /**
  * \ingroup simix_process_management
@@ -552,7 +582,7 @@ void simcall_vm_destroy(smx_host_t vm)
  * \param properties the properties of the process
  * \param auto_restart either it is autorestarting or not.
  */
-void simcall_process_create(smx_process_t *process, const char *name,
+smx_process_t simcall_process_create(const char *name,
                               xbt_main_func_t code,
                               void *data,
                               const char *hostname,
@@ -561,7 +591,7 @@ void simcall_process_create(smx_process_t *process, const char *name,
                               xbt_dict_t properties,
                               int auto_restart)
 {
-  simcall_BODY_process_create(process, name, code, data, hostname,
+  return (smx_process_t) simcall_BODY_process_create(name, code, data, hostname,
                               kill_time, argc, argv, properties,
                               auto_restart);
 }
@@ -607,7 +637,7 @@ void simcall_process_cleanup(smx_process_t process)
  * \param process the process to migrate
  * \param dest name of the new host
  */
-void simcall_process_change_host(smx_process_t process, smx_host_t dest)
+void simcall_process_change_host(smx_process_t process, sg_host_t dest)
 {
   simcall_BODY_process_change_host(process, dest);
 }
@@ -737,8 +767,8 @@ void simcall_process_set_kill_time(smx_process_t process, double kill_time)
   if (kill_time > SIMIX_get_clock()) {
     if (simix_global->kill_process_function) {
       XBT_DEBUG("Set kill time %f for process %s(%s)",kill_time, process->name,
-          sg_host_name(process->smx_host));
-      SIMIX_timer_set(kill_time, simix_global->kill_process_function, process);
+          sg_host_name(process->host));
+      process->kill_timer = SIMIX_timer_set(kill_time, simix_global->kill_process_function, process);
     }
   }
 }
@@ -747,12 +777,12 @@ void simcall_process_set_kill_time(smx_process_t process, double kill_time)
  * \ingroup simix_process_management
  * \brief Return the location on which an agent is running.
  *
- * This functions returns the smx_host_t corresponding to the location on which
+ * This functions returns the sg_host_t corresponding to the location on which
  * \a process is running.
  * \param process SIMIX process
  * \return SIMIX host
  */
-smx_host_t simcall_process_get_host(smx_process_t process)
+sg_host_t simcall_process_get_host(smx_process_t process)
 {
   return simcall_BODY_process_get_host(process);
 }
@@ -887,7 +917,7 @@ smx_rdv_t simcall_rdv_get_by_name(const char *name)
  *  \param host The host to be counted
  *  \return The number of comm synchros pending in the rdv
  */
-int simcall_rdv_comm_count_by_host(smx_rdv_t rdv, smx_host_t host)
+int simcall_rdv_comm_count_by_host(smx_rdv_t rdv, sg_host_t host)
 {
   return simcall_BODY_rdv_comm_count_by_host(rdv, host);
 }
@@ -1308,7 +1338,7 @@ int simcall_sem_get_capacity(smx_sem_t sem)
  * \ingroup simix_file_management
  *
  */
-sg_size_t simcall_file_read(smx_file_t fd, sg_size_t size, smx_host_t host)
+sg_size_t simcall_file_read(smx_file_t fd, sg_size_t size, sg_host_t host)
 {
   return simcall_BODY_file_read(fd, size, host);
 }
@@ -1317,7 +1347,7 @@ sg_size_t simcall_file_read(smx_file_t fd, sg_size_t size, smx_host_t host)
  * \ingroup simix_file_management
  *
  */
-sg_size_t simcall_file_write(smx_file_t fd, sg_size_t size, smx_host_t host)
+sg_size_t simcall_file_write(smx_file_t fd, sg_size_t size, sg_host_t host)
 {
   return simcall_BODY_file_write(fd, size, host);
 }
@@ -1326,7 +1356,7 @@ sg_size_t simcall_file_write(smx_file_t fd, sg_size_t size, smx_host_t host)
  * \ingroup simix_file_management
  * \brief
  */
-smx_file_t simcall_file_open(const char* fullpath, smx_host_t host)
+smx_file_t simcall_file_open(const char* fullpath, sg_host_t host)
 {
   return simcall_BODY_file_open(fullpath, host);
 }
@@ -1335,7 +1365,7 @@ smx_file_t simcall_file_open(const char* fullpath, smx_host_t host)
  * \ingroup simix_file_management
  *
  */
-int simcall_file_close(smx_file_t fd, smx_host_t host)
+int simcall_file_close(smx_file_t fd, sg_host_t host)
 {
   return simcall_BODY_file_close(fd, host);
 }
@@ -1344,7 +1374,7 @@ int simcall_file_close(smx_file_t fd, smx_host_t host)
  * \ingroup simix_file_management
  *
  */
-int simcall_file_unlink(smx_file_t fd, smx_host_t host)
+int simcall_file_unlink(smx_file_t fd, sg_host_t host)
 {
   return simcall_BODY_file_unlink(fd, host);
 }
@@ -1418,7 +1448,7 @@ sg_size_t simcall_storage_get_used_size (smx_storage_t storage){
  * \param host A SIMIX host
  * \return a dict containing all storages mounted on the host
  */
-xbt_dict_t simcall_host_get_mounted_storage_list(smx_host_t host)
+xbt_dict_t simcall_host_get_mounted_storage_list(sg_host_t host)
 {
   return simcall_BODY_host_get_mounted_storage_list(host);
 }
@@ -1429,7 +1459,7 @@ xbt_dict_t simcall_host_get_mounted_storage_list(smx_host_t host)
  * \param host A SIMIX host
  * \return a dict containing all storages attached to the host
  */
-xbt_dynar_t simcall_host_get_attached_storage_list(smx_host_t host)
+xbt_dynar_t simcall_host_get_attached_storage_list(sg_host_t host)
 {
   return simcall_BODY_host_get_attached_storage_list(host);
 }