Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add MSG_host_on and MSG_host_off
[simgrid.git] / src / simix / smx_host.c
1 /* Copyright (c) 2007-2012. The SimGrid Team.
2  * All rights reserved.                                                     */
3
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. */
6
7 #include "smx_private.h"
8 #include "xbt/sysdep.h"
9 #include "xbt/log.h"
10 #include "xbt/dict.h"
11 #include "mc/mc.h"
12
13 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_host, simix,
14                                 "Logging specific to SIMIX (hosts)");
15
16 static void SIMIX_execution_finish(smx_action_t action);
17
18 /**
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)
23  */
24 smx_host_t SIMIX_host_create(const char *name,
25                                void *workstation, void *data)
26 {
27   smx_host_priv_t smx_host = xbt_new0(s_smx_host_priv_t, 1);
28   s_smx_process_t proc;
29
30   /* Host structure */
31   smx_host->data = data;
32   smx_host->process_list =
33       xbt_swag_new(xbt_swag_offset(proc, host_proc_hookup));
34
35   /* Update global variables */
36   xbt_lib_set(host_lib,name,SIMIX_HOST_LEVEL,smx_host);
37   
38   return xbt_lib_get_elm_or_null(host_lib, name);
39 }
40
41 void SIMIX_pre_host_on(smx_host_t h)
42 {
43   SIMIX_host_on(h);
44 }
45
46 /**
47  * \brief Start the host if it is off
48  *
49  */
50 void SIMIX_host_on(smx_host_t h)
51 {
52   smx_host_priv_t host = (smx_host_priv_t) h;
53
54   xbt_assert((host != NULL), "Invalid parameters");
55   
56   surf_model_t ws_model = surf_resource_model(h, SURF_WKS_LEVEL);
57   ws_model->extension.workstation.set_state(host, SURF_RESOURCE_ON);
58
59   SIMIX_host_restart_processes(h);
60 }
61
62 void SIMIX_pre_host_off(smx_host_t h)
63 {
64   SIMIX_host_off(h);
65 }
66
67 /**
68  * \brief Stop the host if it is on
69  *
70  */
71 void SIMIX_host_off(smx_host_t h)
72 {
73   smx_host_priv_t host = (smx_host_priv_t) h;
74
75   xbt_assert((host != NULL), "Invalid parameters");
76
77   /* Clean Simulator data */
78   if (xbt_swag_size(host->process_list) != 0) {
79     char *msg = xbt_strdup("Shutting down host, but it's not empty:");
80     char *tmp;
81     smx_process_t process = NULL;
82
83     xbt_swag_foreach(process, host->process_list) {
84       tmp = bprintf("%s\n\t%s", msg, process->name);
85       free(msg);
86       msg = tmp;
87     }
88     SIMIX_display_process_status();
89     THROWF(arg_error, 0, "%s", msg);
90   }
91   xbt_swag_free(host->process_list);
92
93   surf_model_t ws_model = surf_resource_model(h, SURF_WKS_LEVEL);
94   ws_model->extension.workstation.set_state(host, SURF_RESOURCE_OFF);
95 }
96
97 /**
98  * \brief Internal function to destroy a SIMIX host.
99  *
100  * \param h the host to destroy (a smx_host_t)
101  */
102 void SIMIX_host_destroy(void *h)
103 {
104   smx_host_priv_t host = (smx_host_priv_t) h;
105
106   xbt_assert((host != NULL), "Invalid parameters");
107
108   /* Clean Simulator data */
109   if (xbt_swag_size(host->process_list) != 0) {
110     char *msg = xbt_strdup("Shutting down host, but it's not empty:");
111     char *tmp;
112     smx_process_t process = NULL;
113
114     xbt_swag_foreach(process, host->process_list) {
115       tmp = bprintf("%s\n\t%s", msg, process->name);
116       free(msg);
117       msg = tmp;
118     }
119     SIMIX_display_process_status();
120     THROWF(arg_error, 0, "%s", msg);
121   }
122   xbt_dynar_free(&host->auto_restart_processes);
123   xbt_swag_free(host->process_list);
124
125   /* Clean host structure */
126   free(host); 
127   return;
128 }
129
130 ///**
131 // * \brief Returns a dict of all hosts.
132 // *
133 // * \return List of all hosts (as a #xbt_dict_t)
134 // */
135 //xbt_dict_t SIMIX_host_get_dict(void)
136 //{
137 //  xbt_dict_t host_dict = xbt_dict_new_homogeneous(NULL);
138 //  xbt_lib_cursor_t cursor = NULL;
139 //  char *name = NULL;
140 //  void **host = NULL;
141 //
142 //  xbt_lib_foreach(host_lib, cursor, name, host){
143 //    if(host[SIMIX_HOST_LEVEL])
144 //            xbt_dict_set(host_dict,name,host[SIMIX_HOST_LEVEL], NULL);
145 //  }
146 //  return host_dict;
147 //}
148 smx_host_t SIMIX_pre_host_get_by_name(smx_simcall_t simcall, const char *name){
149    return SIMIX_host_get_by_name(name);
150 }
151 smx_host_t SIMIX_host_get_by_name(const char *name){
152   xbt_assert(((simix_global != NULL)
153                && (host_lib != NULL)),
154               "Environment not set yet");
155
156   return xbt_lib_get_elm_or_null(host_lib, name);
157 }
158
159 smx_host_t SIMIX_host_self(void)
160 {
161   smx_process_t process = SIMIX_process_self();
162   return (process == NULL) ? NULL : SIMIX_process_get_host(process);
163 }
164
165 const char* SIMIX_pre_host_self_get_name(smx_simcall_t simcall){
166    return SIMIX_host_self_get_name();
167 }
168 /* needs to be public and without simcall because it is called
169    by exceptions and logging events */
170 const char* SIMIX_host_self_get_name(void)
171 {
172   smx_host_t host = SIMIX_host_self();
173   if (host == NULL || SIMIX_process_self() == simix_global->maestro_process)
174     return "";
175
176   return SIMIX_host_get_name(host);
177 }
178
179 const char* SIMIX_pre_host_get_name(smx_simcall_t simcall, smx_host_t host){
180    return SIMIX_host_get_name(host);
181 }
182 const char* SIMIX_host_get_name(smx_host_t host){
183   xbt_assert((host != NULL), "Invalid parameters");
184
185   return sg_host_name(host);
186 }
187
188 xbt_dict_t SIMIX_pre_host_get_properties(smx_simcall_t simcall, smx_host_t host){
189   return SIMIX_host_get_properties(host);
190 }
191 xbt_dict_t SIMIX_host_get_properties(smx_host_t host){
192   xbt_assert((host != NULL), "Invalid parameters (simix host is NULL)");
193
194   surf_model_t ws_model = surf_resource_model(host, SURF_WKS_LEVEL);
195   return ws_model->extension.workstation.get_properties(host);
196 }
197
198 double SIMIX_pre_host_get_speed(smx_simcall_t simcall, smx_host_t host){
199   return SIMIX_host_get_speed(host);
200 }
201 double SIMIX_host_get_speed(smx_host_t host){
202   xbt_assert((host != NULL), "Invalid parameters (simix host is NULL)");
203
204   surf_model_t ws_model = surf_resource_model(host, SURF_WKS_LEVEL);
205   return ws_model->extension.workstation.get_speed(host, 1.0);
206 }
207
208 double SIMIX_pre_host_get_available_speed(smx_simcall_t simcall, smx_host_t host){
209   return SIMIX_host_get_available_speed(host);
210 }
211 double SIMIX_host_get_available_speed(smx_host_t host){
212   xbt_assert((host != NULL), "Invalid parameters (simix host is NULL)");
213
214   surf_model_t ws_model = surf_resource_model(host, SURF_WKS_LEVEL);
215   return ws_model->extension.workstation.get_available_speed(host);
216 }
217
218 int SIMIX_pre_host_get_state(smx_simcall_t simcall, smx_host_t host){
219   return SIMIX_host_get_state(host);
220 }
221 int SIMIX_host_get_state(smx_host_t host){
222   xbt_assert((host != NULL), "Invalid parameters (simix host is NULL)");
223
224   surf_model_t ws_model = surf_resource_model(host, SURF_WKS_LEVEL);
225   return ws_model->extension.workstation.get_state(host);
226 }
227
228 void* SIMIX_pre_host_self_get_data(smx_simcall_t simcall){
229   return SIMIX_host_self_get_data();
230 }
231 void* SIMIX_host_self_get_data(void)
232 {
233   smx_host_t self = SIMIX_host_self();
234   return SIMIX_host_get_data(self);
235 }
236
237 void SIMIX_host_self_set_data(void *data)
238 {
239   smx_host_t self = SIMIX_host_self();
240   SIMIX_host_set_data(self, data);
241 }
242
243 void* SIMIX_pre_host_get_data(smx_simcall_t simcall,smx_host_t host){
244   return SIMIX_host_get_data(host);
245 }
246 void* SIMIX_host_get_data(smx_host_t host){
247   xbt_assert((host != NULL), "Invalid parameters (simix host is NULL)");
248
249   return SIMIX_host_priv(host)->data;
250 }
251 void _SIMIX_host_free_process_arg(void *);
252 void _SIMIX_host_free_process_arg(void *data)
253 {
254   smx_process_arg_t arg = *(void**)data;
255   xbt_free(arg->name);
256   xbt_free(arg);
257 }
258 /**
259  * \brief Add a process to the list of the processes that the host will restart when it comes back
260  * This function add a process to the list of the processes that will be restarted when the host comes
261  * back. It is expected that this function is called when the host is down.
262  * The processes will only be restarted once, meaning that you will have to register the process
263  * again to restart the process again.
264  */
265 void SIMIX_host_add_auto_restart_process(smx_host_t host,
266                                          const char *name,
267                                          xbt_main_func_t code,
268                                          void *data,
269                                          const char *hostname,
270                                          double kill_time,
271                                          int argc, char **argv,
272                                          xbt_dict_t properties,
273                                          int auto_restart)
274 {
275   if (!SIMIX_host_priv(host)->auto_restart_processes) {
276     SIMIX_host_priv(host)->auto_restart_processes = xbt_dynar_new(sizeof(smx_process_arg_t),_SIMIX_host_free_process_arg);
277   }
278   smx_process_arg_t arg = xbt_new(s_smx_process_arg_t,1);
279   arg->name = xbt_strdup(name);
280   arg->code = code;
281   arg->data = data;
282   arg->hostname = hostname;
283   arg->kill_time = kill_time;
284   arg->argc = argc;
285
286   arg->argv = xbt_new(char*,argc + 1);
287
288   int i;
289   for (i = 0; i < argc; i++) {
290     arg->argv[i] = xbt_strdup(argv[i]);
291   }
292   arg->argv[argc] = NULL;
293
294   arg->properties = properties;
295   arg->auto_restart = auto_restart;
296
297   if( SIMIX_host_get_state(host) == SURF_RESOURCE_OFF
298       && !xbt_dict_get_or_null(watched_hosts_lib,sg_host_name(host))){
299     xbt_dict_set(watched_hosts_lib,sg_host_name(host),host,NULL);
300     XBT_DEBUG("Have push host %s to watched_hosts_lib because state == SURF_RESOURCE_OFF",sg_host_name(host));
301   }
302   xbt_dynar_push_as(SIMIX_host_priv(host)->auto_restart_processes,smx_process_arg_t,arg);
303 }
304 /**
305  * \brief Restart the list of processes that have been registered to the host
306  */
307 void SIMIX_host_restart_processes(smx_host_t host)
308 {
309   unsigned int cpt;
310   smx_process_arg_t arg;
311   xbt_dynar_foreach(SIMIX_host_priv(host)->auto_restart_processes,cpt,arg) {
312
313     smx_process_t process;
314
315     XBT_DEBUG("Restarting Process %s(%s) right now", arg->argv[0], arg->hostname);
316     if (simix_global->create_process_function) {
317       simix_global->create_process_function(&process,
318                                             arg->argv[0],
319                                             arg->code,
320                                             NULL,
321                                             arg->hostname,
322                                             arg->kill_time,
323                                             arg->argc,
324                                             arg->argv,
325                                             arg->properties,
326                                             arg->auto_restart);
327     }
328     else {
329       simcall_process_create(&process,
330                                             arg->argv[0],
331                                             arg->code,
332                                             NULL,
333                                             arg->hostname,
334                                             arg->kill_time,
335                                             arg->argc,
336                                             arg->argv,
337                                             arg->properties,
338                                             arg->auto_restart);
339
340     }
341   }
342   xbt_dynar_reset(SIMIX_host_priv(host)->auto_restart_processes);
343 }
344
345 void SIMIX_host_autorestart(smx_host_t host)
346 {
347   if(simix_global->autorestart)
348     simix_global->autorestart(host);
349   else
350     xbt_die("No function for simix_global->autorestart");
351 }
352
353 void SIMIX_pre_host_set_data(smx_simcall_t simcall, smx_host_t host, void *data) {
354   SIMIX_host_set_data(host, data);
355 }
356 void SIMIX_host_set_data(smx_host_t host, void *data){
357   xbt_assert((host != NULL), "Invalid parameters");
358   xbt_assert((SIMIX_host_priv(host)->data == NULL), "Data already set");
359
360   SIMIX_host_priv(host)->data = data;
361 }
362
363 smx_action_t SIMIX_pre_host_execute(smx_simcall_t simcall,const char *name,
364     smx_host_t host, double computation_amount, double priority, double bound){
365   return SIMIX_host_execute(name, host, computation_amount, priority, bound);
366 }
367 smx_action_t SIMIX_host_execute(const char *name,
368     smx_host_t host, double computation_amount, double priority, double bound){
369
370   /* alloc structures and initialize */
371   smx_action_t action = xbt_mallocator_get(simix_global->action_mallocator);
372   action->type = SIMIX_ACTION_EXECUTE;
373   action->name = xbt_strdup(name);
374   action->state = SIMIX_RUNNING;
375   action->execution.host = host;
376
377 #ifdef HAVE_TRACING
378   action->category = NULL;
379 #endif
380
381   surf_model_t ws_model = surf_resource_model(host, SURF_WKS_LEVEL);
382   /* set surf's action */
383   if (!MC_is_active()) {
384     action->execution.surf_exec = ws_model->extension.workstation.execute(host, computation_amount);
385     ws_model->action_data_set(action->execution.surf_exec, action);
386     ws_model->set_priority(action->execution.surf_exec, priority);
387     ws_model->set_bound(action->execution.surf_exec, bound);
388   }
389
390   XBT_DEBUG("Create execute action %p", action);
391
392   return action;
393 }
394
395 smx_action_t SIMIX_pre_host_parallel_execute(smx_simcall_t simcall, const char *name,
396     int host_nb, smx_host_t *host_list,
397     double *computation_amount, double *communication_amount,
398     double amount, double rate){
399   return SIMIX_host_parallel_execute(name, host_nb, host_list, computation_amount,
400                                      communication_amount, amount, rate);
401 }
402 smx_action_t SIMIX_host_parallel_execute(const char *name,
403     int host_nb, smx_host_t *host_list,
404     double *computation_amount, double *communication_amount,
405     double amount, double rate){
406
407   void **workstation_list = NULL;
408   int i;
409
410   /* alloc structures and initialize */
411   smx_action_t action = xbt_mallocator_get(simix_global->action_mallocator);
412   action->type = SIMIX_ACTION_PARALLEL_EXECUTE;
413   action->name = xbt_strdup(name);
414   action->state = SIMIX_RUNNING;
415   action->execution.host = NULL; /* FIXME: do we need the list of hosts? */
416
417 #ifdef HAVE_TRACING
418   action->category = NULL;
419 #endif
420
421   /* set surf's action */
422   workstation_list = xbt_new0(void *, host_nb);
423   for (i = 0; i < host_nb; i++)
424     workstation_list[i] = host_list[i];
425
426
427   /* FIXME: what happens if host_list contains VMs and PMs. If
428    * execute_parallel_task() does not change the state of the model, we can mix
429    * them. */
430   surf_model_t ws_model = surf_resource_model(host_list[0], SURF_WKS_LEVEL);
431   for (i = 1; i < host_nb; i++) {
432     surf_model_t ws_model_tmp = surf_resource_model(host_list[i], SURF_WKS_LEVEL);
433     if (ws_model_tmp != ws_model) {
434       XBT_CRITICAL("mixing VMs and PMs is not supported");
435       DIE_IMPOSSIBLE;
436     }
437   }
438
439   /* set surf's action */
440   if (!MC_is_active()) {
441     action->execution.surf_exec =
442       ws_model->extension.workstation.
443       execute_parallel_task(host_nb, workstation_list, computation_amount,
444                       communication_amount, rate);
445
446     ws_model->action_data_set(action->execution.surf_exec, action);
447   }
448   XBT_DEBUG("Create parallel execute action %p", action);
449
450   return action;
451 }
452
453 static surf_model_t get_ws_model_from_action(smx_action_t action)
454 {
455   xbt_assert(action->type == SIMIX_ACTION_EXECUTE);
456   smx_host_t host = action->execution.host;
457   surf_model_t model = surf_resource_model(host, SURF_WKS_LEVEL);
458
459   xbt_assert((model == surf_workstation_model) || (model == surf_vm_workstation_model));
460
461   return model;
462 }
463
464 void SIMIX_pre_host_execution_destroy(smx_simcall_t simcall, smx_action_t action){
465   SIMIX_host_execution_destroy(action);
466 }
467 void SIMIX_host_execution_destroy(smx_action_t action){
468   XBT_DEBUG("Destroy action %p", action);
469
470   surf_model_t ws_model = get_ws_model_from_action(action);
471
472   if (action->execution.surf_exec) {
473     ws_model->action_unref(action->execution.surf_exec);
474     action->execution.surf_exec = NULL;
475   }
476   xbt_free(action->name);
477   xbt_mallocator_release(simix_global->action_mallocator, action);
478 }
479
480 void SIMIX_pre_host_execution_cancel(smx_simcall_t simcall, smx_action_t action){
481   SIMIX_host_execution_cancel(action);
482 }
483 void SIMIX_host_execution_cancel(smx_action_t action){
484   XBT_DEBUG("Cancel action %p", action);
485
486   surf_model_t ws_model = get_ws_model_from_action(action);
487
488   if (action->execution.surf_exec)
489     ws_model->action_cancel(action->execution.surf_exec);
490 }
491
492 double SIMIX_pre_host_execution_get_remains(smx_simcall_t simcall, smx_action_t action){
493   return SIMIX_host_execution_get_remains(action);
494 }
495 double SIMIX_host_execution_get_remains(smx_action_t action){
496   double result = 0.0;
497   surf_model_t ws_model = get_ws_model_from_action(action);
498
499   if (action->state == SIMIX_RUNNING)
500     result = ws_model->get_remains(action->execution.surf_exec);
501
502   return result;
503 }
504
505 e_smx_state_t SIMIX_pre_host_execution_get_state(smx_simcall_t simcall, smx_action_t action){
506   return SIMIX_host_execution_get_state(action);
507 }
508 e_smx_state_t SIMIX_host_execution_get_state(smx_action_t action){
509   return action->state;
510 }
511
512 void SIMIX_pre_host_execution_set_priority(smx_simcall_t simcall, smx_action_t action,
513                                         double priority){
514   SIMIX_host_execution_set_priority(action, priority);
515 }
516 void SIMIX_host_execution_set_priority(smx_action_t action, double priority){
517   surf_model_t ws_model = get_ws_model_from_action(action);
518
519   if(action->execution.surf_exec)
520     ws_model->set_priority(action->execution.surf_exec, priority);
521 }
522
523 void SIMIX_pre_host_execution_set_bound(smx_simcall_t simcall, smx_action_t action,
524                                         double bound){
525   SIMIX_host_execution_set_bound(action, bound);
526 }
527 void SIMIX_host_execution_set_bound(smx_action_t action, double bound){
528   surf_model_t ws_model = get_ws_model_from_action(action);
529
530   if(action->execution.surf_exec)
531     ws_model->set_bound(action->execution.surf_exec, bound);
532 }
533
534 void SIMIX_pre_host_execution_wait(smx_simcall_t simcall, smx_action_t action){
535
536   XBT_DEBUG("Wait for execution of action %p, state %d", action, (int)action->state);
537
538   /* Associate this simcall to the action */
539   xbt_fifo_push(action->simcalls, simcall);
540   simcall->issuer->waiting_action = action;
541
542   /* set surf's action */
543   if (MC_is_active()) {
544     action->state = SIMIX_DONE;
545     SIMIX_execution_finish(action);
546     return;
547   }
548
549   /* If the action is already finished then perform the error handling */
550   if (action->state != SIMIX_RUNNING)
551     SIMIX_execution_finish(action);
552 }
553
554 void SIMIX_host_execution_suspend(smx_action_t action)
555 {
556   surf_model_t ws_model = get_ws_model_from_action(action);
557
558   if(action->execution.surf_exec)
559     ws_model->suspend(action->execution.surf_exec);
560 }
561
562 void SIMIX_host_execution_resume(smx_action_t action)
563 {
564   surf_model_t ws_model = get_ws_model_from_action(action);
565
566   if(action->execution.surf_exec)
567     ws_model->resume(action->execution.surf_exec);
568 }
569
570 void SIMIX_execution_finish(smx_action_t action)
571 {
572   xbt_fifo_item_t item;
573   smx_simcall_t simcall;
574   surf_model_t ws_model = get_ws_model_from_action(action);
575
576   xbt_fifo_foreach(action->simcalls, item, simcall, smx_simcall_t) {
577
578     switch (action->state) {
579
580       case SIMIX_DONE:
581         /* do nothing, action done */
582   XBT_DEBUG("SIMIX_execution_finished: execution successful");
583         break;
584
585       case SIMIX_FAILED:
586         XBT_DEBUG("SIMIX_execution_finished: host '%s' failed", sg_host_name(simcall->issuer->smx_host));
587         simcall->issuer->context->iwannadie = 1;
588         //SMX_EXCEPTION(simcall->issuer, host_error, 0, "Host failed");
589         break;
590
591       case SIMIX_CANCELED:
592         XBT_DEBUG("SIMIX_execution_finished: execution canceled");
593         SMX_EXCEPTION(simcall->issuer, cancel_error, 0, "Canceled");
594         break;
595
596       default:
597         xbt_die("Internal error in SIMIX_execution_finish: unexpected action state %d",
598             (int)action->state);
599     }
600     /* check if the host is down */
601     if (ws_model->extension.workstation.get_state(simcall->issuer->smx_host) != SURF_RESOURCE_ON) {
602       simcall->issuer->context->iwannadie = 1;
603     }
604
605     simcall->issuer->waiting_action =    NULL;
606     simcall_host_execution_wait__set__result(simcall, action->state);
607     SIMIX_simcall_answer(simcall);
608   }
609
610   /* We no longer need it */
611   SIMIX_host_execution_destroy(action);
612 }
613
614
615 void SIMIX_post_host_execute(smx_action_t action)
616 {
617   surf_model_t ws_model = get_ws_model_from_action(action);
618
619   if (action->type == SIMIX_ACTION_EXECUTE && /* FIMXE: handle resource failure
620                                                * for parallel tasks too */
621       ws_model->extension.workstation.get_state(action->execution.host) == SURF_RESOURCE_OFF) {
622     /* If the host running the action failed, notice it so that the asking
623      * process can be killed if it runs on that host itself */
624     action->state = SIMIX_FAILED;
625   } else if (ws_model->action_state_get(action->execution.surf_exec) == SURF_ACTION_FAILED) {
626     /* If the host running the action didn't fail, then the action was
627      * canceled */
628     action->state = SIMIX_CANCELED;
629   } else {
630     action->state = SIMIX_DONE;
631   }
632
633   if (action->execution.surf_exec) {
634     ws_model->action_unref(action->execution.surf_exec);
635     action->execution.surf_exec = NULL;
636   }
637
638   /* If there are simcalls associated with the action, then answer them */
639   if (xbt_fifo_size(action->simcalls)) {
640     SIMIX_execution_finish(action);
641   }
642 }
643
644
645 #ifdef HAVE_TRACING
646 void SIMIX_pre_set_category(smx_simcall_t simcall, smx_action_t action,
647                             const char *category){
648   SIMIX_set_category(action, category);
649 }
650 void SIMIX_set_category(smx_action_t action, const char *category)
651 {
652   surf_model_t ws_model = get_ws_model_from_action(action);
653
654   if (action->state != SIMIX_RUNNING) return;
655   if (action->type == SIMIX_ACTION_EXECUTE){
656     ws_model->set_category(action->execution.surf_exec, category);
657   }else if (action->type == SIMIX_ACTION_COMMUNICATE){
658     ws_model->set_category(action->comm.surf_comm, category);
659   }
660 }
661 #endif
662
663
664 /**
665  * \brief Function to get the parameters of the given the SIMIX host.
666  *
667  * \param host the host to get_phys_host (a smx_host_t)
668  * \param param the parameter object space to be overwritten (a ws_params_t)
669  */
670 void SIMIX_host_get_params(smx_host_t ind_vm, ws_params_t params)
671 {
672   /* jump to ws_get_params(). */
673   surf_workstation_model->extension.workstation.get_params(ind_vm, params);
674 }
675
676 void SIMIX_pre_host_get_params(smx_simcall_t simcall, smx_host_t ind_vm, ws_params_t params)
677 {
678   SIMIX_host_get_params(ind_vm, params);
679   SIMIX_simcall_answer(simcall);
680 }
681
682 void SIMIX_host_set_params(smx_host_t ind_vm, ws_params_t params)
683 {
684   /* jump to ws_set_params(). */
685   surf_workstation_model->extension.workstation.set_params(ind_vm, params);
686 }
687
688 void SIMIX_pre_host_set_params(smx_simcall_t simcall, smx_host_t ind_vm, ws_params_t params)
689 {
690   SIMIX_host_set_params(ind_vm, params);
691   SIMIX_simcall_answer(simcall);
692 }