Logo AND Algorithmique Numérique Distribuée

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