1 #include "network_constant.hpp"
2 #include "surf/random_mgr.h"
4 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_network);
5 static random_data_t random_latency = NULL;
6 static int host_number_int = 0;
8 static void netcste_count_hosts(sg_platf_host_cbarg_t h) {
15 void surf_network_model_init_Constant()
17 xbt_assert(surf_network_model == NULL);
18 surf_network_model = new NetworkConstantModel();
21 random_latency = random_new(RAND, 100, 0.0, 1.0, .125, .034);
23 sg_platf_host_add_cb(netcste_count_hosts);
25 ModelPtr model = static_cast<ModelPtr>(surf_network_model);
26 xbt_dynar_push(model_list, &model);
28 routing_model_create(NULL);
31 double NetworkConstantModel::shareResources(double now)
34 NetworkConstantActionLmmPtr action = NULL;
37 xbt_swag_foreach(_action, p_runningActionSet) {
38 action = dynamic_cast<NetworkConstantActionLmmPtr>(static_cast<ActionPtr>(_action));
39 if (action->m_latency > 0) {
41 min = action->m_latency;
42 else if (action->m_latency < min)
43 min = action->m_latency;
50 void NetworkConstantModel::updateActionsState(double now, double delta)
52 void *_action, *_next_action;
53 NetworkConstantActionLmmPtr action = NULL;
55 xbt_swag_foreach_safe(_action, _next_action, p_runningActionSet) {
56 action = dynamic_cast<NetworkConstantActionLmmPtr>(static_cast<ActionPtr>(_action));
57 if (action->m_latency > 0) {
58 if (action->m_latency > delta) {
59 double_update(&(action->m_latency), delta);
61 action->m_latency = 0.0;
64 double_update(&(action->m_remains),
65 action->m_cost * delta / action->m_latInit);
66 if (action->m_maxDuration != NO_MAX_DURATION)
67 double_update(&(action->m_maxDuration), delta);
69 if (action->m_remains <= 0) {
70 action->m_finish = surf_get_clock();
71 action->setState(SURF_ACTION_DONE);
72 } else if ((action->m_maxDuration != NO_MAX_DURATION)
73 && (action->m_maxDuration <= 0)) {
74 action->m_finish = surf_get_clock();
75 action->setState(SURF_ACTION_DONE);
80 ActionPtr NetworkConstantModel::communicate(RoutingEdgePtr src, RoutingEdgePtr dst,
81 double size, double rate)
83 char *src_name = src->p_name;
84 char *dst_name = dst->p_name;
86 XBT_IN("(%s,%s,%g,%g)", src_name, dst_name, size, rate);
87 NetworkConstantActionLmmPtr action = new NetworkConstantActionLmm(this, sg_latency_factor);
96 bool NetworkConstantLinkLmm::isUsed()
101 void NetworkConstantLinkLmm::updateState(tmgr_trace_event_t event_type,
102 double value, double time)
107 double NetworkConstantLinkLmm::getBandwidth()
110 return -1.0; /* useless since DIE actually abort(), but eclipse prefer to have a useless and harmless return */
113 double NetworkConstantLinkLmm::getLatency()
116 return -1.0; /* useless since DIE actually abort(), but eclipse prefer to have a useless and harmless return */
119 bool NetworkConstantLinkLmm::isShared()
122 return -1; /* useless since DIE actually abort(), but eclipse prefer to have a useless and harmless return */
129 int NetworkConstantActionLmm::unref()
133 xbt_swag_remove(static_cast<ActionPtr>(this), p_stateSet);
140 void NetworkConstantActionLmm::cancel()
146 void NetworkConstantActionLmm::setCategory(const char *category)
148 //ignore completely the categories in constant model, they are not traced
152 void NetworkConstantActionLmm::suspend()
157 void NetworkConstantActionLmm::resume()
163 void NetworkConstantActionLmm::recycle()
168 bool NetworkConstantActionLmm::isSuspended()