*/
typedef struct msg_task *msg_task_t;
-/* ******************************** VM ************************************* */
-typedef struct msg_vm *msg_vm_t;
-
-typedef enum {
- msg_vm_state_suspended, msg_vm_state_running, msg_vm_state_migrating
-} e_msg_vm_state_t;
-
-typedef struct msg_vm {
- char *name;
- s_xbt_swag_hookup_t all_vms_hookup;
- s_xbt_swag_hookup_t host_vms_hookup;
- xbt_dynar_t processes;
- e_msg_vm_state_t state;
- msg_host_t location;
- int coreAmount;
-} s_msg_vm_t;
+/* ******************************** VM ************************************* */
+typedef msg_host_t msg_vm_t;
+typedef msg_host_priv_t msg_vm_priv_t;
+
+static inline msg_vm_priv_t MSG_vm_priv(msg_vm_t vm){
+ return xbt_lib_get_level(vm, MSG_HOST_LEVEL);
+}
-
/* ******************************** File ************************************ */
typedef struct simdata_file *simdata_file_t;
* \brief Initializes the CPU model with trace integration [Deprecated]
*
* You shouldn't have to call it by yourself.
- * \see surf_workstation_model_init_CLM03()
*/
-XBT_PUBLIC(void) surf_cpu_model_init_ti(void);
+XBT_PUBLIC(surf_model_t) surf_cpu_model_init_ti(void);
- /** \brief This function call the share resources function needed
- *
- */
- XBT_PUBLIC(double) generic_share_resources(double now);
-
- /** \brief This function call the update action state function needed
- *
- */
- XBT_PUBLIC(void) generic_update_actions_state(double now, double delta);
-
/** \ingroup SURF_models
* \brief The list of all available optimization modes (both for cpu and networks).
* These optimization modes can be set using --cfg=cpu/optim:... and --cfg=network/optim:...
#endif
}
-/** @brief Immediately kills all processes within the given VM. Any memory that they allocated will be leaked.
+
+/** @brief Immediately save the execution of all processes within the given VM.
* @ingroup msg_VMs
*
- * No extra delay occurs. If you want to simulate this too, you want to
- * use a #MSG_process_sleep() or something. I'm not quite sure.
+ * This function stops the exection of the VM. All the processes on this VM
+ * will pause. The state of the VM is perserved. We can later resume it again.
+ *
+ * FIXME: No suspension cost occurs. If you want to simulate this too, you want to
+ * use a \ref MSG_file_write() before or after, depending on the exact semantic
+ * of VM save to you.
*/
-void MSG_vm_shutdown(msg_vm_t vm)
+void MSG_vm_save(msg_vm_t vm)
{
- msg_process_t process;
- XBT_DEBUG("%lu processes in the VM", xbt_dynar_length(vm->processes));
- while (!xbt_dynar_is_empty(vm->processes)) {
- process = xbt_dynar_get_as(vm->processes,0,msg_process_t);
- MSG_process_kill(process);
- }
-
+ simcall_vm_save(vm);
-
#ifdef HAVE_TRACING
- TRACE_msg_vm_kill(vm);
+ TRACE_msg_vm_save(vm);
#endif
-
}
-
-/**
- * \ingroup msg_VMs
- * \brief Reboot the VM, restarting all the processes in it.
+/** @brief Restore the execution of the VM. All processes on the VM run again.
+ * @ingroup msg_VMs
+ *
+ * FIXME: No restore cost occurs. If you want to simulate this too, you want to
+ * use a \ref MSG_file_read() before or after, depending on the exact semantic
+ * of VM restore to you.
*/
-void MSG_vm_reboot(msg_vm_t vm)
+void MSG_vm_restore(msg_vm_t vm)
{
- xbt_dynar_t process_list = xbt_dynar_new(sizeof(msg_process_t), NULL);
- msg_process_t process;
- unsigned int cpt;
-
- xbt_dynar_foreach(vm->processes, cpt, process) {
- xbt_dynar_push_as(process_list, msg_process_t, process);
- }
+ simcall_vm_restore(vm);
- xbt_dynar_foreach(process_list, cpt, process) {
- msg_process_t new_process = MSG_process_restart(process);
- MSG_vm_bind(vm, new_process);
- }
-
- xbt_dynar_free(&process_list);
+ #ifdef HAVE_TRACING
+ TRACE_msg_vm_restore(vm);
+ #endif
}
-/** @brief Destroy a msg_vm_t.
+
+/** @brief Destroy a VM. Destroy the VM object from the simulation.
* @ingroup msg_VMs
*/
-void MSG_vm_destroy(msg_vm_t vm) {
- unsigned int cpt;
- msg_process_t process;
- xbt_dynar_foreach(vm->processes,cpt,process) {
- //FIXME: Slow ?
- simdata_process_t simdata = simcall_process_get_data(process);
- simdata->vm = NULL;
- }
+void MSG_vm_destroy(msg_vm_t vm)
+{
+ /* First, terminate all processes on the VM */
+ simcall_vm_shutdown(vm);
+
+ /* Then, destroy the VM object */
+ simcall_vm_destroy(vm);
#ifdef HAVE_TRACING
TRACE_msg_vm_end(vm);
surf_cpu_model_init_Cas01();
surf_network_model_init_LegrandVelho();
+ /* surf_cpu_mode_pm and surf_network_model must be initialized in advance. */
+ xbt_assert(surf_cpu_model_pm);
+ xbt_assert(surf_network_model);
+ surf_workstation_model_init_internal();
+
xbt_dynar_push(model_list, &surf_workstation_model);
+ xbt_dynar_push(model_list_invoke, &surf_workstation_model);
sg_platf_host_add_cb(workstation_new);
- // sg_platf_postparse_add_cb(create_workstations);
}
void surf_workstation_model_init_compound()
{
-
- xbt_assert(surf_cpu_model, "No CPU model defined yet!");
+ xbt_assert(surf_cpu_model_pm, "No CPU model defined yet!");
xbt_assert(surf_network_model, "No network model defined yet!");
+
surf_workstation_model_init_internal();
xbt_dynar_push(model_list, &surf_workstation_model);
+ xbt_dynar_push(model_list_invoke, &surf_workstation_model);
sg_platf_host_add_cb(workstation_new);
- // sg_platf_postparse_add_cb(create_workstations);
}