1 /* Copyright (c) 2004, 2005, 2006, 2007, 2008, 2009, 2010. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
6 #ifndef _SURF_SURF_PRIVATE_H
7 #define _SURF_SURF_PRIVATE_H
10 #include "surf/maxmin.h"
11 #include "surf/trace_mgr.h"
13 #include "surf/surfxml_parse_private.h"
14 #include "surf/random_mgr.h"
15 #include "instr/private.h"
17 #define NO_MAX_DURATION -1.0
19 /* user-visible parameters */
20 extern double sg_tcp_gamma;
21 extern double sg_latency_factor;
22 extern double sg_bandwidth_factor;
23 extern double sg_weight_S_parameter;
24 extern int sg_maxmin_selective_update;
25 extern int sg_network_fullduplex;
27 extern double sg_gtnets_jitter;
28 extern int sg_gtnets_jitter_seed;
32 extern const char *surf_action_state_names[6];
34 typedef struct surf_model_private {
35 int (*resource_used) (void *resource_id);
36 /* Share the resources to the actions and return in how much time
37 the next action may terminate */
38 double (*share_resources) (double now);
39 /* Update the actions' state */
40 void (*update_actions_state) (double now, double delta);
41 void (*update_resource_state) (void *id, tmgr_trace_event_t event_type,
42 double value, double time);
43 void (*finalize) (void);
44 } s_surf_model_private_t;
46 double generic_maxmin_share_resources(xbt_swag_t running_actions,
49 void (*solve) (lmm_system_t));
51 /* Generic functions common to all models */
52 e_surf_action_state_t surf_action_state_get(surf_action_t action); /* cannot declare inline since we use a pointer to it */
53 double surf_action_get_start_time(surf_action_t action); /* cannot declare inline since we use a pointer to it */
54 double surf_action_get_finish_time(surf_action_t action); /* cannot declare inline since we use a pointer to it */
55 void surf_action_free(surf_action_t * action);
56 void surf_action_state_set(surf_action_t action, e_surf_action_state_t state);
57 void surf_action_data_set(surf_action_t action, void *data); /* cannot declare inline since we use a pointer to it */
58 FILE *surf_fopen(const char *name, const char *mode);
60 extern tmgr_history_t history;
61 extern xbt_dynar_t surf_path;
63 void surf_config_init(int *argc, char **argv);
64 void surf_config_finalize(void);
65 void surf_config(const char *name, va_list pa);
67 void net_action_recycle(surf_action_t action);
68 double net_action_get_remains(surf_action_t action);
69 int net_get_link_latency(surf_action_t action);
70 void net_action_set_max_duration(surf_action_t action, double duration);
72 * Returns the initial path. On Windows the initial path is
73 * the current directory for the current process in the other
74 * case the function returns "./" that represents the current
75 * directory on Unix/Linux platforms.
77 const char *__surf_get_initial_path(void);
79 /* The __surf_is_absolute_file_path() returns 1 if
80 * file_path is a absolute file path, in the other
81 * case the function returns 0.
83 int __surf_is_absolute_file_path(const char *file_path);
86 * One link routing list
92 }s_onelink, *s_onelink_t;
99 SURF_NETWORK_ELEMENT_NULL = 0, /* NULL */
100 SURF_NETWORK_ELEMENT_HOST, /* host type */
101 SURF_NETWORK_ELEMENT_ROUTER, /* router type */
102 SURF_NETWORK_ELEMENT_GATEWAY, /* gateway type of the AS */
103 SURF_NETWORK_ELEMENT_AS, /* AS type */
104 SURF_NETWORK_ELEMENT_AS_GATEWAY, /* gateway type for internals AS */
105 SURF_NETWORK_ELEMENT_LINK /* link type */
106 } e_surf_network_element_type_t;
108 typedef struct s_model_type s_model_type_t, *model_type_t;
109 typedef struct s_network_element s_network_element_t, *network_element_t;
110 typedef struct s_route s_route_t, *route_t;
111 typedef struct s_route_limits s_route_limits_t, *route_limits_t;
112 typedef struct s_route_extended s_route_extended_t, *route_extended_t;
113 typedef struct s_routing_component s_routing_component_t, *routing_component_t;
114 //typedef struct s_routing_global s_routing_global_t, *routing_global_t;
116 struct s_model_type {
125 struct s_network_element {
127 e_surf_network_element_type_t type;
131 xbt_dynar_t link_list;
134 struct s_route_limits {
139 struct s_route_extended {
140 s_route_t generic_route;
145 /* This enum used in the routing structure helps knowing in which situation we are. */
147 SURF_ROUTING_NULL = 0, /**< Indefined type */
148 SURF_ROUTING_BASE, /**< Base case: use simple link lists for routing */
149 SURF_ROUTING_RECURSIVE /**< Recursive case: also return gateway informations */
150 } e_surf_routing_hierarchy_t;
152 struct s_routing_component {
153 model_type_t routing;
154 e_surf_routing_hierarchy_t hierarchy;
156 struct s_routing_component* routing_father;
157 xbt_dict_t routing_sons;
158 route_extended_t (*get_route)(routing_component_t rc, const char* src, const char* dst);
159 route_extended_t (*get_bypass_route)(routing_component_t rc, const char* src, const char* dst);
160 void (*finalize)(routing_component_t rc);
161 void (*set_processing_unit)(routing_component_t rc, const char* name);
162 void (*set_autonomous_system)(routing_component_t rc, const char* name);
163 void (*set_route)(routing_component_t rc, const char* src, const char* dst, route_t route);
164 void (*set_ASroute)(routing_component_t rc, const char* src, const char* dst, route_extended_t route);
165 void (*set_bypassroute)(routing_component_t rc, const char* src, const char* dst, route_extended_t e_route);
168 struct s_routing_global {
169 routing_component_t root;
170 xbt_dict_t where_network_elements; /* char* -> s_routing_component* */
173 xbt_dynar_t (*get_route)(const char* src, const char* dst);
174 xbt_dict_t (*get_onelink_routes)(void);
175 int (*is_router)(const char *name);
176 void (*finalize)(void);
177 xbt_dynar_t last_route;
180 XBT_PUBLIC(void) routing_model_create(size_t size_of_link,void *loopback);
183 * Resource protected methods
185 xbt_dict_t surf_resource_properties(const void *resource);
187 XBT_PUBLIC(void) surfxml_bufferstack_push(int new);
188 XBT_PUBLIC(void) surfxml_bufferstack_pop(int new);
190 XBT_PUBLIC_DATA(int) surfxml_bufferstack_size;
192 #endif /* _SURF_SURF_PRIVATE_H */