1 #include "network_constant.hpp"
2 #include "surf/random_mgr.h"
4 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_network);
5 static int host_number_int = 0;
7 static void netcste_count_hosts(sg_platf_host_cbarg_t /*h*/) {
14 void surf_network_model_init_Constant()
16 xbt_assert(surf_network_model == NULL);
17 surf_network_model = new NetworkConstantModel();
19 sg_platf_host_add_cb(netcste_count_hosts);
21 ModelPtr model = static_cast<ModelPtr>(surf_network_model);
22 xbt_dynar_push(model_list, &model);
25 double NetworkConstantModel::shareResources(double /*now*/)
27 NetworkConstantActionPtr action = NULL;
30 ActionListPtr actionSet = getRunningActionSet();
31 for(ActionList::iterator it(actionSet->begin()), itend(actionSet->end())
32 ; it != itend ; ++it) {
33 action = static_cast<NetworkConstantActionPtr>(&*it);
34 if (action->m_latency > 0) {
36 min = action->m_latency;
37 else if (action->m_latency < min)
38 min = action->m_latency;
45 void NetworkConstantModel::updateActionsState(double /*now*/, double delta)
47 NetworkConstantActionPtr action = NULL;
48 ActionListPtr actionSet = getRunningActionSet();
49 for(ActionList::iterator it(actionSet->begin()), itNext=it, itend(actionSet->end())
50 ; it != itend ; it=itNext) {
52 action = static_cast<NetworkConstantActionPtr>(&*it);
53 if (action->m_latency > 0) {
54 if (action->m_latency > delta) {
55 double_update(&(action->m_latency), delta);
57 action->m_latency = 0.0;
60 action->updateRemains(action->getCost() * delta / action->m_latInit);
61 if (action->getMaxDuration() != NO_MAX_DURATION)
62 action->updateMaxDuration(delta);
64 if (action->getRemains() <= 0) {
66 action->setState(SURF_ACTION_DONE);
67 } else if ((action->getMaxDuration() != NO_MAX_DURATION)
68 && (action->getMaxDuration() <= 0)) {
70 action->setState(SURF_ACTION_DONE);
75 ActionPtr NetworkConstantModel::communicate(RoutingEdgePtr src, RoutingEdgePtr dst,
76 double size, double rate)
78 char *src_name = src->p_name;
79 char *dst_name = dst->p_name;
81 XBT_IN("(%s,%s,%g,%g)", src_name, dst_name, size, rate);
82 NetworkConstantActionPtr action = new NetworkConstantAction(this, size, sg_latency_factor);
91 bool NetworkConstantLink::isUsed()
96 void NetworkConstantLink::updateState(tmgr_trace_event_t /*event_type*/,
97 double /*value*/, double /*time*/)
102 double NetworkConstantLink::getBandwidth()
105 return -1.0; /* useless since DIE actually abort(), but eclipse prefer to have a useless and harmless return */
108 double NetworkConstantLink::getLatency()
111 return -1.0; /* useless since DIE actually abort(), but eclipse prefer to have a useless and harmless return */
114 bool NetworkConstantLink::isShared()
117 return -1; /* useless since DIE actually abort(), but eclipse prefer to have a useless and harmless return */
124 int NetworkConstantAction::unref()
128 if (actionHook::is_linked())
129 p_stateSet->erase(p_stateSet->iterator_to(*this));
136 void NetworkConstantAction::cancel()
142 void NetworkConstantAction::setCategory(const char */*category*/)
144 //ignore completely the categories in constant model, they are not traced
148 void NetworkConstantAction::suspend()
153 void NetworkConstantAction::resume()
159 void NetworkConstantAction::recycle()
164 bool NetworkConstantAction::isSuspended()