1 #include "simdag/simdag.h"
3 #include "xbt/asserts.h"
4 #include "xbt/sysdep.h"
7 #define CHECK_INIT_DONE() xbt_assert0(init_done, "SG_init not called yet")
9 SG_global_t sg_global = NULL;
11 static int init_done = 0;
13 /* Initialises SG internal data. This function should be called before any other SG function.
15 void SG_init(int *argc, char **argv) {
16 xbt_assert0(!init_done, "SG_init already called");
18 sg_global = xbt_new0(s_SG_global_t, 1);
19 sg_global->workstations = xbt_dict_new();
20 sg_global->workstation_count = 0;
22 surf_init(argc, argv);
27 /* Creates the environnement described in a xml file of a platform descriptions.
29 void SG_create_environment(const char *platform_file) {
30 xbt_dict_cursor_t cursor = NULL;
32 void *workstation = NULL;
35 surf_timer_resource_init(platform_file);
36 surf_workstation_resource_init_KCCFLN05(platform_file); /* tell Surf to create the environnement */
38 /* now let's create the SG wrappers */
39 xbt_dict_foreach(workstation_set, cursor, name, workstation) {
40 __SG_workstation_create(name, workstation, NULL);
44 /* Launches the simulation. Returns a NULL-terminated array of SG_task_t whose state has changed.
46 SG_task_t* SG_simulate(double how_long)
50 /* temporary test to access to the surf workstation structure */
51 xbt_dict_cursor_t cursor = NULL;
53 void *workstation = NULL;
54 const char *surf_name;
57 xbt_dict_foreach(workstation_set, cursor, name, workstation) {
58 surf_name = surf_workstation_resource->common_public->get_resource_name(workstation);
59 speed = surf_workstation_resource->extension_public->get_speed(workstation, 1.0);
60 printf("Workstation name: %s, Surf name: %s, speed: %d\n", name, surf_name, speed);
66 /* Destroys all SG data. This function should be called when the simulation is over.
70 xbt_dict_free(&sg_global->workstations);
73 /* TODO: destroy the workstations, the links and the tasks */