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*/)
28 NetworkConstantActionLmmPtr action = NULL;
31 xbt_swag_foreach(_action, p_runningActionSet) {
32 action = dynamic_cast<NetworkConstantActionLmmPtr>(static_cast<ActionPtr>(_action));
33 if (action->m_latency > 0) {
35 min = action->m_latency;
36 else if (action->m_latency < min)
37 min = action->m_latency;
44 void NetworkConstantModel::updateActionsState(double /*now*/, double delta)
46 void *_action, *_next_action;
47 NetworkConstantActionLmmPtr action = NULL;
49 xbt_swag_foreach_safe(_action, _next_action, p_runningActionSet) {
50 action = dynamic_cast<NetworkConstantActionLmmPtr>(static_cast<ActionPtr>(_action));
51 if (action->m_latency > 0) {
52 if (action->m_latency > delta) {
53 double_update(&(action->m_latency), delta);
55 action->m_latency = 0.0;
58 double_update(&(action->m_remains),
59 action->m_cost * delta / action->m_latInit);
60 if (action->m_maxDuration != NO_MAX_DURATION)
61 double_update(&(action->m_maxDuration), delta);
63 if (action->m_remains <= 0) {
64 action->m_finish = surf_get_clock();
65 action->setState(SURF_ACTION_DONE);
66 } else if ((action->m_maxDuration != NO_MAX_DURATION)
67 && (action->m_maxDuration <= 0)) {
68 action->m_finish = surf_get_clock();
69 action->setState(SURF_ACTION_DONE);
74 ActionPtr NetworkConstantModel::communicate(RoutingEdgePtr src, RoutingEdgePtr dst,
75 double size, double rate)
77 char *src_name = src->p_name;
78 char *dst_name = dst->p_name;
80 XBT_IN("(%s,%s,%g,%g)", src_name, dst_name, size, rate);
81 NetworkConstantActionLmmPtr action = new NetworkConstantActionLmm(this, size, sg_latency_factor);
90 bool NetworkConstantLinkLmm::isUsed()
95 void NetworkConstantLinkLmm::updateState(tmgr_trace_event_t /*event_type*/,
96 double /*value*/, double /*time*/)
101 double NetworkConstantLinkLmm::getBandwidth()
104 return -1.0; /* useless since DIE actually abort(), but eclipse prefer to have a useless and harmless return */
107 double NetworkConstantLinkLmm::getLatency()
110 return -1.0; /* useless since DIE actually abort(), but eclipse prefer to have a useless and harmless return */
113 bool NetworkConstantLinkLmm::isShared()
116 return -1; /* useless since DIE actually abort(), but eclipse prefer to have a useless and harmless return */
123 int NetworkConstantActionLmm::unref()
127 xbt_swag_remove(static_cast<ActionPtr>(this), p_stateSet);
134 void NetworkConstantActionLmm::cancel()
140 void NetworkConstantActionLmm::setCategory(const char */*category*/)
142 //ignore completely the categories in constant model, they are not traced
146 void NetworkConstantActionLmm::suspend()
151 void NetworkConstantActionLmm::resume()
157 void NetworkConstantActionLmm::recycle()
162 bool NetworkConstantActionLmm::isSuspended()