1 /* Copyright (c) 2007-2013. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
7 #include "smx_private.h"
8 #include "xbt/sysdep.h"
13 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_host, simix,
14 "Logging specific to SIMIX (hosts)");
16 static void SIMIX_execution_finish(smx_action_t action);
19 * \brief Internal function to create a SIMIX host.
20 * \param name name of the host to create
21 * \param workstation the SURF workstation to encapsulate
22 * \param data some user data (may be NULL)
24 smx_host_t SIMIX_host_create(const char *name,
25 void *workstation, void *data)
27 smx_host_priv_t smx_host = xbt_new0(s_smx_host_priv_t, 1);
31 smx_host->data = data;
32 smx_host->process_list =
33 xbt_swag_new(xbt_swag_offset(proc, host_proc_hookup));
35 /* Update global variables */
36 xbt_lib_set(host_lib,name,SIMIX_HOST_LEVEL,smx_host);
38 return xbt_lib_get_or_null(host_lib, name, SIMIX_HOST_LEVEL);
41 void SIMIX_pre_host_on(smx_simcall_t simcall, smx_host_t h)
47 * \brief Start the host if it is off
50 void SIMIX_host_on(smx_host_t h)
52 smx_host_priv_t host = SIMIX_host_priv(h);
54 xbt_assert((host != NULL), "Invalid parameters");
56 surf_model_t ws_model = surf_resource_model(h, SURF_WKS_LEVEL);
57 if (ws_model->extension.workstation.get_state(h)==SURF_RESOURCE_OFF) {
58 ws_model->extension.workstation.set_state(h, SURF_RESOURCE_ON);
60 smx_process_arg_t arg;
61 xbt_dynar_foreach(host->boot_processes,cpt,arg) {
62 smx_process_t process;
64 XBT_DEBUG("Booting Process %s(%s) right now", arg->argv[0], arg->hostname);
65 if (simix_global->create_process_function) {
66 simix_global->create_process_function(&process,
78 simcall_process_create(&process,
93 void SIMIX_pre_host_off(smx_simcall_t simcall, smx_host_t h)
95 SIMIX_host_off(h, simcall->issuer);
99 * \brief Stop the host if it is on
102 void SIMIX_host_off(smx_host_t h, smx_process_t issuer)
104 smx_host_priv_t host = SIMIX_host_priv(h);
106 xbt_assert((host != NULL), "Invalid parameters");
108 surf_model_t ws_model = surf_resource_model(h, SURF_WKS_LEVEL);
109 if (ws_model->extension.workstation.get_state(h)==SURF_RESOURCE_ON) {
110 ws_model->extension.workstation.set_state(h, SURF_RESOURCE_OFF);
112 /* Clean Simulator data */
113 if (xbt_swag_size(host->process_list) != 0) {
114 smx_process_t process = NULL;
115 xbt_swag_foreach(process, host->process_list) {
116 SIMIX_process_kill(process, issuer);
117 XBT_DEBUG("Killing %s on %s by %s", process->name, sg_host_name(process->smx_host), issuer->name);
124 * \brief Internal function to destroy a SIMIX host.
126 * \param h the host to destroy (a smx_host_t)
128 void SIMIX_host_destroy(void *h)
130 smx_host_priv_t host = (smx_host_priv_t) h;
132 xbt_assert((host != NULL), "Invalid parameters");
134 /* Clean Simulator data */
135 if (xbt_swag_size(host->process_list) != 0) {
136 char *msg = xbt_strdup("Shutting down host, but it's not empty:");
138 smx_process_t process = NULL;
140 xbt_swag_foreach(process, host->process_list) {
141 tmp = bprintf("%s\n\t%s", msg, process->name);
145 SIMIX_display_process_status();
146 THROWF(arg_error, 0, "%s", msg);
148 xbt_dynar_free(&host->auto_restart_processes);
149 xbt_dynar_free(&host->boot_processes);
150 xbt_swag_free(host->process_list);
152 /* Clean host structure */
158 // * \brief Returns a dict of all hosts.
160 // * \return List of all hosts (as a #xbt_dict_t)
162 //xbt_dict_t SIMIX_host_get_dict(void)
164 // xbt_dict_t host_dict = xbt_dict_new_homogeneous(NULL);
165 // xbt_lib_cursor_t cursor = NULL;
166 // char *name = NULL;
167 // void **host = NULL;
169 // xbt_lib_foreach(host_lib, cursor, name, host){
170 // if(host[SIMIX_HOST_LEVEL])
171 // xbt_dict_set(host_dict,name,host[SIMIX_HOST_LEVEL], NULL);
175 smx_host_t SIMIX_pre_host_get_by_name(smx_simcall_t simcall, const char *name){
176 return SIMIX_host_get_by_name(name);
178 smx_host_t SIMIX_host_get_by_name(const char *name){
179 xbt_assert(((simix_global != NULL)
180 && (host_lib != NULL)),
181 "Environment not set yet");
183 return xbt_lib_get_elm_or_null(host_lib, name);
186 smx_host_t SIMIX_host_self(void)
188 smx_process_t process = SIMIX_process_self();
189 return (process == NULL) ? NULL : SIMIX_process_get_host(process);
192 const char* SIMIX_pre_host_self_get_name(smx_simcall_t simcall){
193 return SIMIX_host_self_get_name();
195 /* needs to be public and without simcall because it is called
196 by exceptions and logging events */
197 const char* SIMIX_host_self_get_name(void)
199 smx_host_t host = SIMIX_host_self();
200 if (host == NULL || SIMIX_process_self() == simix_global->maestro_process)
203 return SIMIX_host_get_name(host);
206 const char* SIMIX_pre_host_get_name(smx_simcall_t simcall, smx_host_t host){
207 return SIMIX_host_get_name(host);
209 const char* SIMIX_host_get_name(smx_host_t host){
210 xbt_assert((host != NULL), "Invalid parameters");
212 return sg_host_name(host);
215 xbt_dict_t SIMIX_pre_host_get_properties(smx_simcall_t simcall, smx_host_t host){
216 return SIMIX_host_get_properties(host);
218 xbt_dict_t SIMIX_host_get_properties(smx_host_t host){
219 xbt_assert((host != NULL), "Invalid parameters (simix host is NULL)");
221 surf_model_t ws_model = surf_resource_model(host, SURF_WKS_LEVEL);
222 return ws_model->extension.workstation.get_properties(host);
225 double SIMIX_pre_host_get_speed(smx_simcall_t simcall, smx_host_t host){
226 return SIMIX_host_get_speed(host);
228 double SIMIX_host_get_speed(smx_host_t host){
229 xbt_assert((host != NULL), "Invalid parameters (simix host is NULL)");
231 surf_model_t ws_model = surf_resource_model(host, SURF_WKS_LEVEL);
232 return ws_model->extension.workstation.get_speed(host, 1.0);
235 int SIMIX_pre_host_get_core(smx_simcall_t simcall, smx_host_t host){
236 return SIMIX_host_get_core(host);
238 int SIMIX_host_get_core(smx_host_t host){
239 xbt_assert((host != NULL), "Invalid parameters (simix host is NULL)");
241 return surf_workstation_model->extension.workstation.
245 xbt_swag_t SIMIX_pre_host_get_process_list(smx_simcall_t simcall, smx_host_t host){
246 return SIMIX_host_get_process_list(host);
249 xbt_swag_t SIMIX_host_get_process_list(smx_host_t host){
250 xbt_assert((host != NULL), "Invalid parameters (simix host is NULL)");
251 smx_host_priv_t host_priv = SIMIX_host_priv(host);
253 return host_priv->process_list;
257 double SIMIX_pre_host_get_available_speed(smx_simcall_t simcall, smx_host_t host){
258 return SIMIX_host_get_available_speed(host);
260 double SIMIX_host_get_available_speed(smx_host_t host){
261 xbt_assert((host != NULL), "Invalid parameters (simix host is NULL)");
263 surf_model_t ws_model = surf_resource_model(host, SURF_WKS_LEVEL);
264 return ws_model->extension.workstation.get_available_speed(host);
267 double SIMIX_pre_host_get_current_power_peak(smx_simcall_t simcall, smx_host_t host){
268 return SIMIX_host_get_current_power_peak(host);
270 double SIMIX_host_get_current_power_peak(smx_host_t host) {
271 xbt_assert((host != NULL), "Invalid parameters (simix host is NULL)");
272 return surf_workstation_model->extension.workstation.
273 get_current_power_peak(host);
276 double SIMIX_pre_host_get_power_peak_at(smx_simcall_t simcall, smx_host_t host, int pstate_index){
277 return SIMIX_host_get_power_peak_at(host, pstate_index);
279 double SIMIX_host_get_power_peak_at(smx_host_t host, int pstate_index) {
280 xbt_assert((host != NULL), "Invalid parameters (simix host is NULL)");
282 return surf_workstation_model->extension.workstation.
283 get_power_peak_at(host, pstate_index);
286 int SIMIX_pre_host_get_nb_pstates(smx_simcall_t simcall, smx_host_t host){
287 return SIMIX_host_get_nb_pstates(host);
289 int SIMIX_host_get_nb_pstates(smx_host_t host) {
290 xbt_assert((host != NULL), "Invalid parameters (simix host is NULL)");
292 return surf_workstation_model->extension.workstation.
293 get_nb_pstates(host);
297 void SIMIX_pre_host_set_power_peak_at(smx_simcall_t simcall, smx_host_t host, int pstate_index){
298 SIMIX_host_set_power_peak_at(host, pstate_index);
300 void SIMIX_host_set_power_peak_at(smx_host_t host, int pstate_index) {
301 xbt_assert((host != NULL), "Invalid parameters (simix host is NULL)");
303 surf_workstation_model->extension.workstation.
304 set_power_peak_at(host, pstate_index);
307 double SIMIX_pre_host_get_consumed_energy(smx_simcall_t simcall, smx_host_t host){
308 return SIMIX_host_get_consumed_energy(host);
310 double SIMIX_host_get_consumed_energy(smx_host_t host) {
311 xbt_assert((host != NULL), "Invalid parameters (simix host is NULL)");
312 return surf_workstation_model->extension.workstation.
313 get_consumed_energy(host);
316 int SIMIX_pre_host_get_state(smx_simcall_t simcall, smx_host_t host){
317 return SIMIX_host_get_state(host);
319 int SIMIX_host_get_state(smx_host_t host){
320 xbt_assert((host != NULL), "Invalid parameters (simix host is NULL)");
322 surf_model_t ws_model = surf_resource_model(host, SURF_WKS_LEVEL);
323 return ws_model->extension.workstation.get_state(host);
326 void* SIMIX_pre_host_self_get_data(smx_simcall_t simcall){
327 return SIMIX_host_self_get_data();
329 void* SIMIX_host_self_get_data(void)
331 smx_host_t self = SIMIX_host_self();
332 return SIMIX_host_get_data(self);
335 void SIMIX_host_self_set_data(void *data)
337 smx_host_t self = SIMIX_host_self();
338 SIMIX_host_set_data(self, data);
341 void* SIMIX_pre_host_get_data(smx_simcall_t simcall,smx_host_t host){
342 return SIMIX_host_get_data(host);
344 void* SIMIX_host_get_data(smx_host_t host){
345 xbt_assert((host != NULL), "Invalid parameters (simix host is NULL)");
347 return SIMIX_host_priv(host)->data;
350 void _SIMIX_host_free_process_arg(void *data)
352 smx_process_arg_t arg = *(void**)data;
354 for (i = 0; i < arg->argc; i++)
355 xbt_free(arg->argv[i]);
361 * \brief Add a process to the list of the processes that the host will restart when it comes back
362 * This function add a process to the list of the processes that will be restarted when the host comes
363 * back. It is expected that this function is called when the host is down.
364 * The processes will only be restarted once, meaning that you will have to register the process
365 * again to restart the process again.
367 void SIMIX_host_add_auto_restart_process(smx_host_t host,
369 xbt_main_func_t code,
371 const char *hostname,
373 int argc, char **argv,
374 xbt_dict_t properties,
377 if (!SIMIX_host_priv(host)->auto_restart_processes) {
378 SIMIX_host_priv(host)->auto_restart_processes = xbt_dynar_new(sizeof(smx_process_arg_t),_SIMIX_host_free_process_arg);
380 smx_process_arg_t arg = xbt_new(s_smx_process_arg_t,1);
381 arg->name = xbt_strdup(name);
384 arg->hostname = hostname;
385 arg->kill_time = kill_time;
388 arg->argv = xbt_new(char*,argc + 1);
391 for (i = 0; i < argc; i++) {
392 arg->argv[i] = xbt_strdup(argv[i]);
394 arg->argv[argc] = NULL;
396 arg->properties = properties;
397 arg->auto_restart = auto_restart;
399 if( SIMIX_host_get_state(host) == SURF_RESOURCE_OFF
400 && !xbt_dict_get_or_null(watched_hosts_lib,sg_host_name(host))){
401 xbt_dict_set(watched_hosts_lib,sg_host_name(host),host,NULL);
402 XBT_DEBUG("Have pushed host %s to watched_hosts_lib because state == SURF_RESOURCE_OFF",sg_host_name(host));
404 xbt_dynar_push_as(SIMIX_host_priv(host)->auto_restart_processes,smx_process_arg_t,arg);
407 * \brief Restart the list of processes that have been registered to the host
409 void SIMIX_host_restart_processes(smx_host_t host)
412 smx_process_arg_t arg;
413 xbt_dynar_t process_list = SIMIX_host_priv(host)->auto_restart_processes;
417 xbt_dynar_foreach (process_list, cpt, arg) {
419 smx_process_t process;
421 XBT_DEBUG("Restarting Process %s(%s) right now", arg->argv[0], arg->hostname);
422 if (simix_global->create_process_function) {
423 simix_global->create_process_function(&process,
434 simcall_process_create(&process,
446 /* arg->argv is used by the process created above. Hide it to
447 * _SIMIX_host_free_process_arg() which is called by xbt_dynar_reset()
452 xbt_dynar_reset(process_list);
455 void SIMIX_host_autorestart(smx_host_t host)
457 if(simix_global->autorestart)
458 simix_global->autorestart(host);
460 xbt_die("No function for simix_global->autorestart");
463 void SIMIX_pre_host_set_data(smx_simcall_t simcall, smx_host_t host, void *data) {
464 SIMIX_host_set_data(host, data);
466 void SIMIX_host_set_data(smx_host_t host, void *data){
467 xbt_assert((host != NULL), "Invalid parameters");
468 xbt_assert((SIMIX_host_priv(host)->data == NULL), "Data already set");
470 SIMIX_host_priv(host)->data = data;
473 smx_action_t SIMIX_pre_host_execute(smx_simcall_t simcall,const char *name,
474 smx_host_t host, double computation_amount, double priority, double bound, unsigned long affinity_mask){
475 return SIMIX_host_execute(name, host, computation_amount, priority, bound, affinity_mask);
477 smx_action_t SIMIX_host_execute(const char *name,
478 smx_host_t host, double computation_amount, double priority, double bound, unsigned long affinity_mask){
480 /* alloc structures and initialize */
481 smx_action_t action = xbt_mallocator_get(simix_global->action_mallocator);
482 action->type = SIMIX_ACTION_EXECUTE;
483 action->name = xbt_strdup(name);
484 action->state = SIMIX_RUNNING;
485 action->execution.host = host;
488 action->category = NULL;
491 surf_model_t ws_model = surf_resource_model(host, SURF_WKS_LEVEL);
492 /* set surf's action */
493 if (!MC_is_active()) {
494 action->execution.surf_exec = ws_model->extension.workstation.execute(host, computation_amount);
495 ws_model->action_data_set(action->execution.surf_exec, action);
496 ws_model->set_priority(action->execution.surf_exec, priority);
498 /* Note (hypervisor): for multicore, the bound value being passed to the
499 * surf layer should not be zero (i.e., unlimited). It should be the
500 * capacity of a CPU core. */
502 ws_model->set_bound(action->execution.surf_exec, SIMIX_host_get_speed(host));
504 ws_model->set_bound(action->execution.surf_exec, bound);
506 if (affinity_mask != 0) {
507 /* just a double check to confirm that this host is the host where this task is running. */
508 xbt_assert(action->execution.host == host);
509 ws_model->set_affinity(action->execution.surf_exec, host, affinity_mask);
513 XBT_DEBUG("Create execute action %p", action);
518 smx_action_t SIMIX_pre_host_parallel_execute(smx_simcall_t simcall, const char *name,
519 int host_nb, smx_host_t *host_list,
520 double *computation_amount, double *communication_amount,
521 double amount, double rate){
522 return SIMIX_host_parallel_execute(name, host_nb, host_list, computation_amount,
523 communication_amount, amount, rate);
525 smx_action_t SIMIX_host_parallel_execute(const char *name,
526 int host_nb, smx_host_t *host_list,
527 double *computation_amount, double *communication_amount,
528 double amount, double rate){
530 void **workstation_list = NULL;
533 /* alloc structures and initialize */
534 smx_action_t action = xbt_mallocator_get(simix_global->action_mallocator);
535 action->type = SIMIX_ACTION_PARALLEL_EXECUTE;
536 action->name = xbt_strdup(name);
537 action->state = SIMIX_RUNNING;
538 action->execution.host = NULL; /* FIXME: do we need the list of hosts? */
541 action->category = NULL;
544 /* set surf's action */
545 workstation_list = xbt_new0(void *, host_nb);
546 for (i = 0; i < host_nb; i++)
547 workstation_list[i] = host_list[i];
550 /* FIXME: what happens if host_list contains VMs and PMs. If
551 * execute_parallel_task() does not change the state of the model, we can mix
553 surf_model_t ws_model = surf_resource_model(host_list[0], SURF_WKS_LEVEL);
554 for (i = 1; i < host_nb; i++) {
555 surf_model_t ws_model_tmp = surf_resource_model(host_list[i], SURF_WKS_LEVEL);
556 if (ws_model_tmp != ws_model) {
557 XBT_CRITICAL("mixing VMs and PMs is not supported");
562 /* set surf's action */
563 if (!MC_is_active()) {
564 action->execution.surf_exec =
565 ws_model->extension.workstation.
566 execute_parallel_task(host_nb, workstation_list, computation_amount,
567 communication_amount, rate);
569 ws_model->action_data_set(action->execution.surf_exec, action);
571 XBT_DEBUG("Create parallel execute action %p", action);
576 static surf_model_t get_ws_model_from_action(smx_action_t action)
578 xbt_assert(action->type == SIMIX_ACTION_EXECUTE);
579 smx_host_t host = action->execution.host;
580 surf_model_t model = surf_resource_model(host, SURF_WKS_LEVEL);
582 xbt_assert((model == surf_workstation_model) || (model == surf_vm_workstation_model));
587 void SIMIX_pre_host_execution_destroy(smx_simcall_t simcall, smx_action_t action){
588 SIMIX_host_execution_destroy(action);
590 void SIMIX_host_execution_destroy(smx_action_t action){
591 XBT_DEBUG("Destroy action %p", action);
593 surf_model_t ws_model = get_ws_model_from_action(action);
595 if (action->execution.surf_exec) {
596 ws_model->action_unref(action->execution.surf_exec);
597 action->execution.surf_exec = NULL;
599 xbt_free(action->name);
600 xbt_mallocator_release(simix_global->action_mallocator, action);
603 void SIMIX_pre_host_execution_cancel(smx_simcall_t simcall, smx_action_t action){
604 SIMIX_host_execution_cancel(action);
606 void SIMIX_host_execution_cancel(smx_action_t action){
607 XBT_DEBUG("Cancel action %p", action);
609 surf_model_t ws_model = get_ws_model_from_action(action);
611 if (action->execution.surf_exec)
612 ws_model->action_cancel(action->execution.surf_exec);
615 double SIMIX_pre_host_execution_get_remains(smx_simcall_t simcall, smx_action_t action){
616 return SIMIX_host_execution_get_remains(action);
618 double SIMIX_host_execution_get_remains(smx_action_t action){
620 surf_model_t ws_model = get_ws_model_from_action(action);
622 if (action->state == SIMIX_RUNNING)
623 result = ws_model->get_remains(action->execution.surf_exec);
628 e_smx_state_t SIMIX_pre_host_execution_get_state(smx_simcall_t simcall, smx_action_t action){
629 return SIMIX_host_execution_get_state(action);
631 e_smx_state_t SIMIX_host_execution_get_state(smx_action_t action){
632 return action->state;
635 void SIMIX_pre_host_execution_set_priority(smx_simcall_t simcall, smx_action_t action,
637 SIMIX_host_execution_set_priority(action, priority);
639 void SIMIX_host_execution_set_priority(smx_action_t action, double priority){
640 surf_model_t ws_model = get_ws_model_from_action(action);
642 if(action->execution.surf_exec)
643 ws_model->set_priority(action->execution.surf_exec, priority);
646 void SIMIX_pre_host_execution_set_bound(smx_simcall_t simcall, smx_action_t action,
648 SIMIX_host_execution_set_bound(action, bound);
650 void SIMIX_host_execution_set_bound(smx_action_t action, double bound){
651 surf_model_t ws_model = get_ws_model_from_action(action);
653 if(action->execution.surf_exec)
654 ws_model->set_bound(action->execution.surf_exec, bound);
657 void SIMIX_pre_host_execution_set_affinity(smx_simcall_t simcall,
658 smx_action_t action, smx_host_t host, unsigned long mask){
659 SIMIX_host_execution_set_affinity(action, host, mask);
661 void SIMIX_host_execution_set_affinity(smx_action_t action, smx_host_t host, unsigned long mask){
662 surf_model_t ws_model = get_ws_model_from_action(action);
664 xbt_assert(action->type == SIMIX_ACTION_EXECUTE);
666 if (action->execution.surf_exec) {
667 /* just a double check to confirm that this host is the host where this task is running. */
668 xbt_assert(action->execution.host == host);
669 ws_model->set_affinity(action->execution.surf_exec, host, mask);
673 void SIMIX_pre_host_execution_wait(smx_simcall_t simcall, smx_action_t action){
675 XBT_DEBUG("Wait for execution of action %p, state %d", action, (int)action->state);
677 /* Associate this simcall to the action */
678 xbt_fifo_push(action->simcalls, simcall);
679 simcall->issuer->waiting_action = action;
681 /* set surf's action */
682 if (MC_is_active()) {
683 action->state = SIMIX_DONE;
684 SIMIX_execution_finish(action);
688 /* If the action is already finished then perform the error handling */
689 if (action->state != SIMIX_RUNNING)
690 SIMIX_execution_finish(action);
693 void SIMIX_host_execution_suspend(smx_action_t action)
695 surf_model_t ws_model = get_ws_model_from_action(action);
697 if(action->execution.surf_exec)
698 ws_model->suspend(action->execution.surf_exec);
701 void SIMIX_host_execution_resume(smx_action_t action)
703 surf_model_t ws_model = get_ws_model_from_action(action);
705 if(action->execution.surf_exec)
706 ws_model->resume(action->execution.surf_exec);
709 void SIMIX_execution_finish(smx_action_t action)
711 xbt_fifo_item_t item;
712 smx_simcall_t simcall;
713 surf_model_t ws_model = get_ws_model_from_action(action);
715 xbt_fifo_foreach(action->simcalls, item, simcall, smx_simcall_t) {
717 switch (action->state) {
720 /* do nothing, action done */
721 XBT_DEBUG("SIMIX_execution_finished: execution successful");
725 XBT_DEBUG("SIMIX_execution_finished: host '%s' failed", sg_host_name(simcall->issuer->smx_host));
726 simcall->issuer->context->iwannadie = 1;
727 SMX_EXCEPTION(simcall->issuer, host_error, 0, "Host failed");
731 XBT_DEBUG("SIMIX_execution_finished: execution canceled");
732 SMX_EXCEPTION(simcall->issuer, cancel_error, 0, "Canceled");
736 xbt_die("Internal error in SIMIX_execution_finish: unexpected action state %d",
739 /* check if the host is down */
740 if (ws_model->extension.workstation.get_state(simcall->issuer->smx_host) != SURF_RESOURCE_ON) {
741 simcall->issuer->context->iwannadie = 1;
744 simcall->issuer->waiting_action = NULL;
745 simcall_host_execution_wait__set__result(simcall, action->state);
746 SIMIX_simcall_answer(simcall);
749 /* We no longer need it */
750 SIMIX_host_execution_destroy(action);
754 void SIMIX_post_host_execute(smx_action_t action)
756 surf_model_t ws_model = get_ws_model_from_action(action);
758 if (action->type == SIMIX_ACTION_EXECUTE && /* FIMXE: handle resource failure
759 * for parallel tasks too */
760 ws_model->extension.workstation.get_state(action->execution.host) == SURF_RESOURCE_OFF) {
761 /* If the host running the action failed, notice it so that the asking
762 * process can be killed if it runs on that host itself */
763 action->state = SIMIX_FAILED;
764 } else if (ws_model->action_state_get(action->execution.surf_exec) == SURF_ACTION_FAILED) {
765 /* If the host running the action didn't fail, then the action was
767 action->state = SIMIX_CANCELED;
769 action->state = SIMIX_DONE;
772 if (action->execution.surf_exec) {
773 ws_model->action_unref(action->execution.surf_exec);
774 action->execution.surf_exec = NULL;
777 /* If there are simcalls associated with the action, then answer them */
778 if (xbt_fifo_size(action->simcalls)) {
779 SIMIX_execution_finish(action);
785 void SIMIX_pre_set_category(smx_simcall_t simcall, smx_action_t action,
786 const char *category){
787 SIMIX_set_category(action, category);
789 void SIMIX_set_category(smx_action_t action, const char *category)
791 surf_model_t ws_model = get_ws_model_from_action(action);
793 if (action->state != SIMIX_RUNNING) return;
794 if (action->type == SIMIX_ACTION_EXECUTE){
795 ws_model->set_category(action->execution.surf_exec, category);
796 }else if (action->type == SIMIX_ACTION_COMMUNICATE){
797 ws_model->set_category(action->comm.surf_comm, category);
803 * \brief Function to get the parameters of the given the SIMIX host.
805 * \param host the host to get_phys_host (a smx_host_t)
806 * \param param the parameter object space to be overwritten (a ws_params_t)
808 void SIMIX_host_get_params(smx_host_t ind_vm, ws_params_t params)
810 /* jump to ws_get_params(). */
811 surf_workstation_model->extension.workstation.get_params(ind_vm, params);
814 void SIMIX_pre_host_get_params(smx_simcall_t simcall, smx_host_t ind_vm, ws_params_t params)
816 SIMIX_host_get_params(ind_vm, params);
819 void SIMIX_host_set_params(smx_host_t ind_vm, ws_params_t params)
821 /* jump to ws_set_params(). */
822 surf_workstation_model->extension.workstation.set_params(ind_vm, params);
825 void SIMIX_pre_host_set_params(smx_simcall_t simcall, smx_host_t ind_vm, ws_params_t params)
827 SIMIX_host_set_params(ind_vm, params);
830 xbt_dict_t SIMIX_pre_host_get_storage_list(smx_simcall_t simcall, smx_host_t host){
831 return SIMIX_host_get_storage_list(host);
834 xbt_dict_t SIMIX_host_get_storage_list(smx_host_t host){
835 xbt_assert((host != NULL), "Invalid parameters (simix host is NULL)");
837 return surf_workstation_model->extension.workstation.get_storage_list(host);