Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
634fd2aac5347d691e38cbd6999752ea0de5c9c7
[simgrid.git] / src / surf / host_ptask_L07.cpp
1 /* Copyright (c) 2007-2010, 2013-2014. 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 "host_ptask_L07.hpp"
8
9 #include "cpu_interface.hpp"
10 #include "surf_routing.hpp"
11
12 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_host);
13
14 static int ptask_host_count = 0;
15 static xbt_dict_t ptask_parallel_task_link_set = NULL;
16 lmm_system_t ptask_maxmin_system = NULL;
17
18
19 /**************************************/
20 /*** Resource Creation & Destruction **/
21 /**************************************/
22
23 static void ptask_netlink_parse_init(sg_platf_link_cbarg_t link)
24 {
25   netlink_parse_init(link);
26   current_property_set = NULL;
27 }
28
29 static void ptask_define_callbacks()
30 {
31   sg_platf_host_add_cb(cpu_parse_init);
32   sg_platf_host_add_cb(host_parse_init);
33   sg_platf_link_add_cb(ptask_netlink_parse_init);
34   sg_platf_postparse_add_cb(host_add_traces);
35 }
36
37 void surf_host_model_init_ptask_L07(void)
38 {
39   XBT_INFO("surf_host_model_init_ptask_L07");
40   xbt_assert(!surf_cpu_model_pm, "CPU model type already defined");
41   xbt_assert(!surf_network_model, "network model type already defined");
42   ptask_define_callbacks();
43   surf_host_model = new HostL07Model();
44   Model *model = surf_host_model;
45   xbt_dynar_push(model_list, &model);
46   xbt_dynar_push(model_list_invoke, &model);
47 }
48
49
50 HostL07Model::HostL07Model() : HostModel("Host ptask_L07") {
51   if (!ptask_maxmin_system)
52         ptask_maxmin_system = lmm_system_new(1);
53   surf_host_model = NULL;
54   surf_network_model = new NetworkL07Model();
55   surf_cpu_model_pm = new CpuL07Model();
56
57   routing_model_create(surf_network_model->createLink("__loopback__",
58                                                           498000000, NULL,
59                                                           0.000015, NULL,
60                                                           SURF_RESOURCE_ON, NULL,
61                                                           SURF_LINK_FATPIPE, NULL));
62   p_cpuModel = surf_cpu_model_pm;
63 }
64
65 HostL07Model::~HostL07Model() {
66   xbt_dict_free(&ptask_parallel_task_link_set);
67
68   delete surf_cpu_model_pm;
69   delete surf_network_model;
70   ptask_host_count = 0;
71
72   if (ptask_maxmin_system) {
73     lmm_system_free(ptask_maxmin_system);
74     ptask_maxmin_system = NULL;
75   }
76 }
77
78 double HostL07Model::shareResources(double /*now*/)
79 {
80   HostL07Action *action;
81
82   ActionList *running_actions = getRunningActionSet();
83   double min = this->shareResourcesMaxMin(running_actions,
84                                               ptask_maxmin_system,
85                                               bottleneck_solve);
86
87   for(ActionList::iterator it(running_actions->begin()), itend(running_actions->end())
88          ; it != itend ; ++it) {
89         action = static_cast<HostL07Action*>(&*it);
90     if (action->m_latency > 0) {
91       if (min < 0) {
92         min = action->m_latency;
93         XBT_DEBUG("Updating min (value) with %p (start %f): %f", action,
94                action->getStartTime(), min);
95       } else if (action->m_latency < min) {
96         min = action->m_latency;
97         XBT_DEBUG("Updating min (latency) with %p (start %f): %f", action,
98                action->getStartTime(), min);
99       }
100     }
101   }
102
103   XBT_DEBUG("min value : %f", min);
104
105   return min;
106 }
107
108 void HostL07Model::updateActionsState(double /*now*/, double delta)
109 {
110   double deltap = 0.0;
111   HostL07Action *action;
112
113   ActionList *actionSet = getRunningActionSet();
114
115   for(ActionList::iterator it(actionSet->begin()), itNext = it, itend(actionSet->end())
116          ; it != itend ; it=itNext) {
117         ++itNext;
118     action = static_cast<HostL07Action*>(&*it);
119     deltap = delta;
120     if (action->m_latency > 0) {
121       if (action->m_latency > deltap) {
122         double_update(&(action->m_latency), deltap, sg_surf_precision);
123         deltap = 0.0;
124       } else {
125         double_update(&(deltap), action->m_latency, sg_surf_precision);
126         action->m_latency = 0.0;
127       }
128       if ((action->m_latency == 0.0) && (action->isSuspended() == 0)) {
129         action->updateBound();
130         lmm_update_variable_weight(ptask_maxmin_system, action->getVariable(), 1.0);
131       }
132     }
133     XBT_DEBUG("Action (%p) : remains (%g) updated by %g.",
134            action, action->getRemains(), lmm_variable_getvalue(action->getVariable()) * delta);
135     action->updateRemains(lmm_variable_getvalue(action->getVariable()) * delta);
136
137     if (action->getMaxDuration() != NO_MAX_DURATION)
138       action->updateMaxDuration(delta);
139
140     XBT_DEBUG("Action (%p) : remains (%g).",
141            action, action->getRemains());
142     if ((action->getRemains() <= 0) &&
143         (lmm_get_variable_weight(action->getVariable()) > 0)) {
144       action->finish();
145       action->setState(SURF_ACTION_DONE);
146     } else if ((action->getMaxDuration() != NO_MAX_DURATION) &&
147                (action->getMaxDuration() <= 0)) {
148       action->finish();
149      action->setState(SURF_ACTION_DONE);
150     } else {
151       /* Need to check that none of the model has failed */
152       lmm_constraint_t cnst = NULL;
153       int i = 0;
154       void *constraint_id = NULL;
155
156       while ((cnst = lmm_get_cnst_from_var(ptask_maxmin_system, action->getVariable(),
157                                     i++))) {
158         constraint_id = lmm_constraint_id(cnst);
159
160         if (static_cast<Host*>(constraint_id)->getState() == SURF_RESOURCE_OFF) {
161           XBT_DEBUG("Action (%p) Failed!!", action);
162           action->finish();
163           action->setState(SURF_ACTION_FAILED);
164           break;
165         }
166       }
167     }
168   }
169   return;
170 }
171
172 Action *HostL07Model::executeParallelTask(int host_nb,
173                                                    void **host_list,
174                                                    double *flops_amount,
175                                                                                                    double *bytes_amount,
176                                                    double rate)
177 {
178   HostL07Action *action;
179   int i, j;
180   unsigned int cpt;
181   int nb_link = 0;
182   int nb_host = 0;
183   double latency = 0.0;
184
185   if (ptask_parallel_task_link_set == NULL)
186     ptask_parallel_task_link_set = xbt_dict_new_homogeneous(NULL);
187
188   xbt_dict_reset(ptask_parallel_task_link_set);
189
190   /* Compute the number of affected resources... */
191   for (i = 0; i < host_nb; i++) {
192     for (j = 0; j < host_nb; j++) {
193       xbt_dynar_t route=NULL;
194
195       if (bytes_amount[i * host_nb + j] > 0) {
196         double lat=0.0;
197         unsigned int cpt;
198         void *_link;
199         LinkL07 *link;
200
201         routing_platf->getRouteAndLatency(static_cast<HostL07*>(host_list[i])->p_netElm,
202                                                   static_cast<HostL07*>(host_list[j])->p_netElm,
203                                                   &route,
204                                                   &lat);
205         latency = MAX(latency, lat);
206
207         xbt_dynar_foreach(route, cpt, _link) {
208            link = static_cast<LinkL07*>(_link);
209            xbt_dict_set(ptask_parallel_task_link_set, link->getName(), link, NULL);
210         }
211       }
212     }
213   }
214
215   nb_link = xbt_dict_length(ptask_parallel_task_link_set);
216   xbt_dict_reset(ptask_parallel_task_link_set);
217
218   for (i = 0; i < host_nb; i++)
219     if (flops_amount[i] > 0)
220       nb_host++;
221
222   action = new HostL07Action(this, 1, 0);
223   XBT_DEBUG("Creating a parallel task (%p) with %d cpus and %d links.",
224          action, host_nb, nb_link);
225   action->m_suspended = 0;        /* Should be useless because of the
226                                    calloc but it seems to help valgrind... */
227   action->m_hostNb = host_nb;
228   action->p_hostList = (Host **) host_list;
229   action->p_computationAmount = flops_amount;
230   action->p_communicationAmount = bytes_amount;
231   action->m_latency = latency;
232   action->m_rate = rate;
233
234   action->p_variable = lmm_variable_new(ptask_maxmin_system, action, 1.0,
235                        (action->m_rate > 0) ? action->m_rate : -1.0,
236                        host_nb + nb_link);
237
238   if (action->m_latency > 0)
239     lmm_update_variable_weight(ptask_maxmin_system, action->getVariable(), 0.0);
240
241   for (i = 0; i < host_nb; i++)
242     lmm_expand(ptask_maxmin_system,
243                  static_cast<HostL07*>(host_list[i])->p_cpu->getConstraint(),
244                action->getVariable(), flops_amount[i]);
245
246   for (i = 0; i < host_nb; i++) {
247     for (j = 0; j < host_nb; j++) {
248       void *_link;
249       LinkL07 *link;
250
251       xbt_dynar_t route=NULL;
252       if (bytes_amount[i * host_nb + j] == 0.0)
253         continue;
254
255       routing_platf->getRouteAndLatency(static_cast<HostL07*>(host_list[i])->p_netElm,
256                                         static_cast<HostL07*>(host_list[j])->p_netElm,
257                                             &route, NULL);
258
259       xbt_dynar_foreach(route, cpt, _link) {
260         link = static_cast<LinkL07*>(_link);
261         lmm_expand_add(ptask_maxmin_system, link->getConstraint(),
262                        action->getVariable(),
263                        bytes_amount[i * host_nb + j]);
264       }
265     }
266   }
267
268   if (nb_link + nb_host == 0) {
269     action->setCost(1.0);
270     action->setRemains(0.0);
271   }
272
273   return action;
274 }
275
276 Host *HostL07Model::createHost(const char *name)
277 {
278   HostL07 *wk = NULL;
279   sg_host_t sg_host = sg_host_by_name(name);
280
281   xbt_assert(!surf_host_resource_priv(sg_host),
282               "Host '%s' declared several times in the platform file.",
283               name);
284
285   wk = new HostL07(this, name, NULL,
286                                   sg_host_edge(sg_host),
287                                                   sg_host_surfcpu(sg_host));
288
289   xbt_lib_set(host_lib, name, SURF_HOST_LEVEL, wk);
290
291   return wk;
292 }
293
294 Action *HostL07Model::communicate(Host *src, Host *dst,
295                                        double size, double rate)
296 {
297   void **host_list = xbt_new0(void *, 2);
298   double *flops_amount = xbt_new0(double, 2);
299   double *bytes_amount = xbt_new0(double, 4);
300   Action *res = NULL;
301
302   host_list[0] = src;
303   host_list[1] = dst;
304   bytes_amount[1] = size;
305
306   res = executeParallelTask(2, host_list,
307                                     flops_amount,
308                                     bytes_amount, rate);
309
310   return res;
311 }
312
313 xbt_dynar_t HostL07Model::getRoute(Host *src, Host *dst)
314 {
315   xbt_dynar_t route=NULL;
316   routing_platf->getRouteAndLatency(src->p_netElm, dst->p_netElm, &route, NULL);
317   return route;
318 }
319
320 Cpu *CpuL07Model::createCpu(const char *name,  xbt_dynar_t powerPeak,
321                           int pstate, double power_scale,
322                           tmgr_trace_t power_trace, int core,
323                           e_surf_resource_state_t state_initial,
324                           tmgr_trace_t state_trace,
325                           xbt_dict_t cpu_properties)
326 {
327   double power_initial = xbt_dynar_get_as(powerPeak, pstate, double);
328   xbt_dynar_free(&powerPeak);   // kill memory leak
329   sg_host_t sg_host = sg_host_by_name(name);
330
331   xbt_assert(!surf_host_resource_priv(sg_host),
332               "Host '%s' declared several times in the platform file.",
333               name);
334
335   CpuL07 *cpu = new CpuL07(this, name, cpu_properties,
336                                      power_initial, power_scale, power_trace,
337                          core, state_initial, state_trace);
338
339   sg_host_surfcpu_set(sg_host, cpu);
340
341   return cpu;
342 }
343
344 Link* NetworkL07Model::createLink(const char *name,
345                                  double bw_initial,
346                                  tmgr_trace_t bw_trace,
347                                  double lat_initial,
348                                  tmgr_trace_t lat_trace,
349                                  e_surf_resource_state_t state_initial,
350                                  tmgr_trace_t state_trace,
351                                  e_surf_link_sharing_policy_t policy,
352                                  xbt_dict_t properties)
353 {
354   xbt_assert(!Link::byName(name),
355                  "Link '%s' declared several times in the platform file.", name);
356
357   return new LinkL07(this, name, properties,
358                              bw_initial, bw_trace,
359                                          lat_initial, lat_trace,
360                                          state_initial, state_trace,
361                                          policy);
362 }
363
364 void HostL07Model::addTraces()
365 {
366   xbt_dict_cursor_t cursor = NULL;
367   char *trace_name, *elm;
368
369   if (!trace_connect_list_host_avail)
370     return;
371
372   /* Connect traces relative to cpu */
373   xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) {
374     tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
375     CpuL07 *host = static_cast<CpuL07*>(sg_host_surfcpu(sg_host_by_name(elm)));
376
377     xbt_assert(host, "Host %s undefined", elm);
378     xbt_assert(trace, "Trace %s undefined", trace_name);
379
380     host->p_stateEvent = tmgr_history_add_trace(history, trace, 0.0, 0, host);
381   }
382
383   xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) {
384     tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
385     CpuL07 *host = static_cast<CpuL07*>(sg_host_surfcpu(sg_host_by_name(elm)));
386
387     xbt_assert(host, "Host %s undefined", elm);
388     xbt_assert(trace, "Trace %s undefined", trace_name);
389
390     host->p_powerEvent = tmgr_history_add_trace(history, trace, 0.0, 0, host);
391   }
392
393   /* Connect traces relative to network */
394   xbt_dict_foreach(trace_connect_list_link_avail, cursor, trace_name, elm) {
395     tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
396     LinkL07 *link = static_cast<LinkL07*>(Link::byName(elm));
397
398     xbt_assert(link, "Link %s undefined", elm);
399     xbt_assert(trace, "Trace %s undefined", trace_name);
400
401     link->p_stateEvent = tmgr_history_add_trace(history, trace, 0.0, 0, link);
402   }
403
404   xbt_dict_foreach(trace_connect_list_bandwidth, cursor, trace_name, elm) {
405     tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
406     LinkL07 *link = static_cast<LinkL07*>(Link::byName(elm));
407
408     xbt_assert(link, "Link %s undefined", elm);
409     xbt_assert(trace, "Trace %s undefined", trace_name);
410
411     link->p_bwEvent = tmgr_history_add_trace(history, trace, 0.0, 0, link);
412   }
413
414   xbt_dict_foreach(trace_connect_list_latency, cursor, trace_name, elm) {
415     tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
416     LinkL07 *link = static_cast<LinkL07*>(Link::byName(elm));
417
418     xbt_assert(link, "Link %s undefined", elm);
419     xbt_assert(trace, "Trace %s undefined", trace_name);
420
421     link->p_latEvent = tmgr_history_add_trace(history, trace, 0.0, 0, link);
422   }
423 }
424
425 /************
426  * Resource *
427  ************/
428
429 HostL07::HostL07(HostModel *model, const char* name, xbt_dict_t props, RoutingEdge *netElm, Cpu *cpu)
430   : Host(model, name, props, NULL, netElm, cpu)
431 {
432 }
433
434 double HostL07::getPowerPeakAt(int /*pstate_index*/)
435 {
436         THROW_UNIMPLEMENTED;
437 }
438
439 int HostL07::getNbPstates()
440 {
441         THROW_UNIMPLEMENTED;
442 }
443
444 void HostL07::setPstate(int /*pstate_index*/)
445 {
446         THROW_UNIMPLEMENTED;
447 }
448
449 int HostL07::getPstate()
450 {
451         THROW_UNIMPLEMENTED;
452 }
453
454 double HostL07::getConsumedEnergy()
455 {
456         THROW_UNIMPLEMENTED;
457 }
458
459 CpuL07::CpuL07(CpuL07Model *model, const char* name, xbt_dict_t props,
460                      double power_initial, double power_scale, tmgr_trace_t power_trace,
461                            int core, e_surf_resource_state_t state_initial, tmgr_trace_t state_trace)
462  : Cpu(model, name, props, lmm_constraint_new(ptask_maxmin_system, this, power_initial * power_scale),
463            core, power_initial, power_scale)
464 {
465   xbt_assert(m_powerScale > 0, "Power has to be >0");
466
467   if (power_trace)
468     p_powerEvent = tmgr_history_add_trace(history, power_trace, 0.0, 0, this);
469   else
470     p_powerEvent = NULL;
471
472   setState(state_initial);
473   if (state_trace)
474         p_stateEvent = tmgr_history_add_trace(history, state_trace, 0.0, 0, this);
475 }
476
477 LinkL07::LinkL07(NetworkL07Model *model, const char* name, xbt_dict_t props,
478                          double bw_initial,
479                          tmgr_trace_t bw_trace,
480                          double lat_initial,
481                          tmgr_trace_t lat_trace,
482                          e_surf_resource_state_t state_initial,
483                          tmgr_trace_t state_trace,
484                          e_surf_link_sharing_policy_t policy)
485  : Link(model, name, props, lmm_constraint_new(ptask_maxmin_system, this, bw_initial), history, state_trace)
486 {
487   m_bwCurrent = bw_initial;
488   if (bw_trace)
489     p_bwEvent = tmgr_history_add_trace(history, bw_trace, 0.0, 0, this);
490
491   setState(state_initial);
492   m_latCurrent = lat_initial;
493
494   if (lat_trace)
495         p_latEvent = tmgr_history_add_trace(history, lat_trace, 0.0, 0, this);
496
497   if (policy == SURF_LINK_FATPIPE)
498         lmm_constraint_shared(getConstraint());
499 }
500
501 bool CpuL07::isUsed(){
502   return lmm_constraint_used(ptask_maxmin_system, getConstraint());
503 }
504
505 bool LinkL07::isUsed(){
506   return lmm_constraint_used(ptask_maxmin_system, getConstraint());
507 }
508
509 void CpuL07::updateState(tmgr_trace_event_t event_type, double value, double /*date*/){
510   XBT_DEBUG("Updating cpu %s (%p) with value %g", getName(), this, value);
511   if (event_type == p_powerEvent) {
512           m_powerScale = value;
513     lmm_update_constraint_bound(ptask_maxmin_system, getConstraint(), m_powerPeak * m_powerScale);
514     if (tmgr_trace_event_free(event_type))
515       p_powerEvent = NULL;
516   } else if (event_type == p_stateEvent) {
517     if (value > 0)
518       setState(SURF_RESOURCE_ON);
519     else
520       setState(SURF_RESOURCE_OFF);
521     if (tmgr_trace_event_free(event_type))
522       p_stateEvent = NULL;
523   } else {
524     XBT_CRITICAL("Unknown event ! \n");
525     xbt_abort();
526   }
527   return;
528 }
529
530 void LinkL07::updateState(tmgr_trace_event_t event_type, double value, double date) {
531   XBT_DEBUG("Updating link %s (%p) with value=%f for date=%g", getName(), this, value, date);
532   if (event_type == p_bwEvent) {
533     updateBandwidth(value, date);
534     if (tmgr_trace_event_free(event_type))
535       p_bwEvent = NULL;
536   } else if (event_type == p_latEvent) {
537     updateLatency(value, date);
538     if (tmgr_trace_event_free(event_type))
539       p_latEvent = NULL;
540   } else if (event_type == p_stateEvent) {
541     if (value > 0)
542       setState(SURF_RESOURCE_ON);
543     else
544       setState(SURF_RESOURCE_OFF);
545     if (tmgr_trace_event_free(event_type))
546       p_stateEvent = NULL;
547   } else {
548     XBT_CRITICAL("Unknown event ! \n");
549     xbt_abort();
550   }
551   return;
552 }
553
554 e_surf_resource_state_t HostL07::getState() {
555   return p_cpu->getState();
556 }
557
558 Action *HostL07::execute(double size)
559 {
560   void **host_list = xbt_new0(void *, 1);
561   double *flops_amount = xbt_new0(double, 1);
562   double *bytes_amount = xbt_new0(double, 1);
563
564   host_list[0] = this;
565   bytes_amount[0] = 0.0;
566   flops_amount[0] = size;
567
568   return static_cast<HostL07Model*>(getModel())->executeParallelTask(1, host_list,
569                                               flops_amount,
570                                      bytes_amount, -1);
571 }
572
573 Action *HostL07::sleep(double duration)
574 {
575   HostL07Action *action = NULL;
576
577   XBT_IN("(%s,%g)", getName(), duration);
578
579   action = static_cast<HostL07Action*>(execute(1.0));
580   action->m_maxDuration = duration;
581   action->m_suspended = 2;
582   lmm_update_variable_weight(ptask_maxmin_system, action->getVariable(), 0.0);
583
584   XBT_OUT();
585   return action;
586 }
587
588 double LinkL07::getBandwidth()
589 {
590   return m_bwCurrent;
591 }
592
593 void LinkL07::updateBandwidth(double value, double date)
594 {
595   m_bwCurrent = value;
596   lmm_update_constraint_bound(ptask_maxmin_system, getConstraint(), m_bwCurrent);
597 }
598
599 double LinkL07::getLatency()
600 {
601   return m_latCurrent;
602 }
603
604 void LinkL07::updateLatency(double value, double date)
605 {
606   lmm_variable_t var = NULL;
607   HostL07Action *action;
608   lmm_element_t elem = NULL;
609
610   m_latCurrent = value;
611   while ((var = lmm_get_var_from_cnst(ptask_maxmin_system, getConstraint(), &elem))) {
612     action = static_cast<HostL07Action*>(lmm_variable_id(var));
613     action->updateBound();
614   }
615 }
616
617
618 bool LinkL07::isShared()
619 {
620   return lmm_constraint_is_shared(getConstraint());
621 }
622
623 /**********
624  * Action *
625  **********/
626
627 HostL07Action::~HostL07Action(){
628   free(p_hostList);
629   free(p_communicationAmount);
630   free(p_computationAmount);
631 }
632
633 void HostL07Action::updateBound()
634 {
635   double lat_current = 0.0;
636   double lat_bound = -1.0;
637   int i, j;
638
639   for (i = 0; i < m_hostNb; i++) {
640     for (j = 0; j < m_hostNb; j++) {
641       xbt_dynar_t route=NULL;
642
643       if (p_communicationAmount[i * m_hostNb + j] > 0) {
644         double lat = 0.0;
645         routing_platf->getRouteAndLatency(static_cast<HostL07*>(((void**)p_hostList)[i])->p_netElm,
646                                           static_cast<HostL07*>(((void**)p_hostList)[j])->p_netElm,
647                                                           &route, &lat);
648
649         lat_current = MAX(lat_current, lat * p_communicationAmount[i * m_hostNb + j]);
650       }
651     }
652   }
653   lat_bound = sg_tcp_gamma / (2.0 * lat_current);
654   XBT_DEBUG("action (%p) : lat_bound = %g", this, lat_bound);
655   if ((m_latency == 0.0) && (m_suspended == 0)) {
656     if (m_rate < 0)
657       lmm_update_variable_bound(ptask_maxmin_system, getVariable(), lat_bound);
658     else
659       lmm_update_variable_bound(ptask_maxmin_system, getVariable(), min(m_rate, lat_bound));
660   }
661 }
662
663 int HostL07Action::unref()
664 {
665   m_refcount--;
666   if (!m_refcount) {
667     if (actionHook::is_linked())
668           p_stateSet->erase(p_stateSet->iterator_to(*this));
669     if (getVariable())
670       lmm_variable_free(ptask_maxmin_system, getVariable());
671     delete this;
672     return 1;
673   }
674   return 0;
675 }
676
677 void HostL07Action::cancel()
678 {
679   setState(SURF_ACTION_FAILED);
680   return;
681 }
682
683 void HostL07Action::suspend()
684 {
685   XBT_IN("(%p))", this);
686   if (m_suspended != 2) {
687     m_suspended = 1;
688     lmm_update_variable_weight(ptask_maxmin_system, getVariable(), 0.0);
689   }
690   XBT_OUT();
691 }
692
693 void HostL07Action::resume()
694 {
695   XBT_IN("(%p)", this);
696   if (m_suspended != 2) {
697     lmm_update_variable_weight(ptask_maxmin_system, getVariable(), 1.0);
698     m_suspended = 0;
699   }
700   XBT_OUT();
701 }
702
703 bool HostL07Action::isSuspended()
704 {
705   return m_suspended == 1;
706 }
707
708 void HostL07Action::setMaxDuration(double duration)
709 {                               /* FIXME: should inherit */
710   XBT_IN("(%p,%g)", this, duration);
711   m_maxDuration = duration;
712   XBT_OUT();
713 }
714
715 void HostL07Action::setPriority(double priority)
716 {                               /* FIXME: should inherit */
717   XBT_IN("(%p,%g)", this, priority);
718   m_priority = priority;
719   XBT_OUT();
720 }
721
722 double HostL07Action::getRemains()
723 {
724   XBT_IN("(%p)", this);
725   XBT_OUT();
726   return m_remains;
727 }