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 //FIXME:sg_platf_host_add_cb(netcste_count_hosts);
25 xbt_dynar_push(model_list, &surf_network_model);
27 //FIXME:routing_model_create(NULL);
30 double NetworkConstantModel::shareResources(double now)
33 NetworkConstantActionLmmPtr action = NULL;
36 xbt_swag_foreach(_action, p_runningActionSet) {
37 action = (NetworkConstantActionLmmPtr) _action;
38 if (action->m_latency > 0) {
40 min = action->m_latency;
41 else if (action->m_latency < min)
42 min = action->m_latency;
49 void NetworkConstantModel::updateActionsState(double now, double delta)
51 void *_action, *_next_action;
52 NetworkConstantActionLmmPtr action = NULL;
54 xbt_swag_foreach_safe(_action, _next_action, p_runningActionSet) {
55 action = (NetworkConstantActionLmmPtr) _action;
56 if (action->m_latency > 0) {
57 if (action->m_latency > delta) {
58 double_update(&(action->m_latency), delta);
60 action->m_latency = 0.0;
63 double_update(&(action->m_remains),
64 action->m_cost * delta / action->m_latInit);
65 if (action->m_maxDuration != NO_MAX_DURATION)
66 double_update(&(action->m_maxDuration), delta);
68 if (action->m_remains <= 0) {
69 action->m_finish = surf_get_clock();
70 action->setState(SURF_ACTION_DONE);
71 } else if ((action->m_maxDuration != NO_MAX_DURATION)
72 && (action->m_maxDuration <= 0)) {
73 action->m_finish = surf_get_clock();
74 action->setState(SURF_ACTION_DONE);
79 NetworkCm02ActionLmmPtr NetworkConstantModel::communicate(RoutingEdgePtr src, RoutingEdgePtr dst,
80 double size, double rate)
82 char *src_name = src->p_name;
83 char *dst_name = dst->p_name;
85 XBT_IN("(%s,%s,%g,%g)", src_name, dst_name, size, rate);
86 NetworkConstantActionLmmPtr action = new NetworkConstantActionLmm(this, sg_latency_factor);
95 bool NetworkConstantLinkLmm::isUsed()
100 void NetworkConstantLinkLmm::updateState(tmgr_trace_event_t event_type,
101 double value, double time)
106 double NetworkConstantLinkLmm::getBandwidth()
109 return -1.0; /* useless since DIE actually abort(), but eclipse prefer to have a useless and harmless return */
112 double NetworkConstantLinkLmm::getLatency()
115 return -1.0; /* useless since DIE actually abort(), but eclipse prefer to have a useless and harmless return */
118 bool NetworkConstantLinkLmm::isShared()
121 return -1; /* useless since DIE actually abort(), but eclipse prefer to have a useless and harmless return */
128 int NetworkConstantActionLmm::unref()
132 xbt_swag_remove(this, p_stateSet);
139 void NetworkConstantActionLmm::cancel()
145 void NetworkConstantActionLmm::setCategory(const char *category)
147 //ignore completely the categories in constant model, they are not traced
151 void NetworkConstantActionLmm::suspend()
156 void NetworkConstantActionLmm::resume()
162 void NetworkConstantActionLmm::recycle()
167 bool NetworkConstantActionLmm::isSuspended()