+ action->generic_action.using = 1;
+ action->generic_action.cost = size;
+ action->generic_action.remains = size;
+ action->generic_action.max_duration = NO_MAX_DURATION;
+ action->generic_action.start = surf_get_clock();
+ action->generic_action.finish = -1.0;
+ action->src = src;
+ action->dst = dst;
+ action->generic_action.resource_type =
+ (surf_resource_t) surf_workstation_resource;
+ action->suspended = 0; /* Should be useless because of the
+ calloc but it seems to help valgrind... */
+ action->generic_action.state_set =
+ surf_workstation_resource->common_public->states.running_action_set;
+
+ xbt_dynar_push(card_src->outgoing_communications, &action);
+ xbt_dynar_push(card_dst->incomming_communications, &action);
+
+ xbt_swag_insert(action, action->generic_action.state_set);
+ action->rate = rate;
+
+ action->latency = 0.0;
+ for (i = 0; i < route_size; i++)
+ action->latency += route->links[i]->lat_current;
+ action->lat_current = action->latency;
+
+ if(action->latency>0)
+ action->variable = lmm_variable_new(maxmin_system, action, 0.0, -1.0,
+ route_size+4); /* +1 for the src bus
+ +1 for the dst bus
+ +1 for the src cpu
+ +1 for the dst cpu */
+ else
+ action->variable = lmm_variable_new(maxmin_system, action, 1.0, -1.0,
+ route_size+4);
+
+ if(action->rate<0) {
+ if(action->lat_current>0)
+ lmm_update_variable_bound(maxmin_system, action->variable,
+ SG_TCP_CTE_GAMMA / (2.0 * action->lat_current));
+ else
+ lmm_update_variable_bound(maxmin_system, action->variable, -1.0);
+ } else {
+ if(action->lat_current>0)
+ lmm_update_variable_bound(maxmin_system, action->variable,
+ min(action->rate,SG_TCP_CTE_GAMMA / (2.0 * action->lat_current)));
+ else
+ lmm_update_variable_bound(maxmin_system, action->variable, action->rate);
+ }
+
+ lmm_update_variable_latency(maxmin_system, action->variable, action->latency);
+
+ for (i = 0; i < route_size; i++)
+ lmm_expand(maxmin_system, route->links[i]->constraint, action->variable, 1.0);
+ if (card_src->bus)
+ lmm_expand(maxmin_system, card_src->bus, action->variable, 1.0);
+ if (card_dst->bus)
+ lmm_expand(maxmin_system, card_dst->bus, action->variable, 1.0);
+ lmm_expand(maxmin_system, card_src->constraint, action->variable, 0.0);
+ lmm_expand(maxmin_system, card_dst->constraint, action->variable, 0.0);
+
+ XBT_OUT;
+ return (surf_action_t) action;