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);
24 routing_model_create(NULL);
27 double NetworkConstantModel::shareResources(double now)
30 NetworkConstantActionLmmPtr action = NULL;
33 xbt_swag_foreach(_action, p_runningActionSet) {
34 action = dynamic_cast<NetworkConstantActionLmmPtr>(static_cast<ActionPtr>(_action));
35 if (action->m_latency > 0) {
37 min = action->m_latency;
38 else if (action->m_latency < min)
39 min = action->m_latency;
46 void NetworkConstantModel::updateActionsState(double now, double delta)
48 void *_action, *_next_action;
49 NetworkConstantActionLmmPtr action = NULL;
51 xbt_swag_foreach_safe(_action, _next_action, p_runningActionSet) {
52 action = dynamic_cast<NetworkConstantActionLmmPtr>(static_cast<ActionPtr>(_action));
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 double_update(&(action->m_remains),
61 action->m_cost * delta / action->m_latInit);
62 if (action->m_maxDuration != NO_MAX_DURATION)
63 double_update(&(action->m_maxDuration), delta);
65 if (action->m_remains <= 0) {
66 action->m_finish = surf_get_clock();
67 action->setState(SURF_ACTION_DONE);
68 } else if ((action->m_maxDuration != NO_MAX_DURATION)
69 && (action->m_maxDuration <= 0)) {
70 action->m_finish = surf_get_clock();
71 action->setState(SURF_ACTION_DONE);
76 ActionPtr NetworkConstantModel::communicate(RoutingEdgePtr src, RoutingEdgePtr dst,
77 double size, double rate)
79 char *src_name = src->p_name;
80 char *dst_name = dst->p_name;
82 XBT_IN("(%s,%s,%g,%g)", src_name, dst_name, size, rate);
83 NetworkConstantActionLmmPtr action = new NetworkConstantActionLmm(this, sg_latency_factor);
92 bool NetworkConstantLinkLmm::isUsed()
97 void NetworkConstantLinkLmm::updateState(tmgr_trace_event_t event_type,
98 double value, double time)
103 double NetworkConstantLinkLmm::getBandwidth()
106 return -1.0; /* useless since DIE actually abort(), but eclipse prefer to have a useless and harmless return */
109 double NetworkConstantLinkLmm::getLatency()
112 return -1.0; /* useless since DIE actually abort(), but eclipse prefer to have a useless and harmless return */
115 bool NetworkConstantLinkLmm::isShared()
118 return -1; /* useless since DIE actually abort(), but eclipse prefer to have a useless and harmless return */
125 int NetworkConstantActionLmm::unref()
129 xbt_swag_remove(static_cast<ActionPtr>(this), p_stateSet);
136 void NetworkConstantActionLmm::cancel()
142 void NetworkConstantActionLmm::setCategory(const char *category)
144 //ignore completely the categories in constant model, they are not traced
148 void NetworkConstantActionLmm::suspend()
153 void NetworkConstantActionLmm::resume()
159 void NetworkConstantActionLmm::recycle()
164 bool NetworkConstantActionLmm::isSuspended()