X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/1e56742544f7195c4cc0525569d610b0ba0e3d8c..6760cb07d6b57be16928d95339d71e57c4e24f36:/src/simdag/sd_link.c diff --git a/src/simdag/sd_link.c b/src/simdag/sd_link.c index e9637b592f..ed84a8bb57 100644 --- a/src/simdag/sd_link.c +++ b/src/simdag/sd_link.c @@ -1,3 +1,9 @@ +/* Copyright (c) 2006, 2007, 2008, 2009, 2010. The SimGrid Team. + * All rights reserved. */ + +/* This program is free software; you can redistribute it and/or modify it + * under the terms of the license (GNU LGPL) which comes with this package. */ + #include "private.h" #include "simdag/simdag.h" #include "xbt/dict.h" @@ -6,7 +12,8 @@ /* Creates a link and registers it in SD. */ -SD_link_t __SD_link_create(void *surf_link, void *data) { +SD_link_t __SD_link_create(void *surf_link, void *data) +{ SD_link_t link; const char *name; @@ -16,14 +23,19 @@ SD_link_t __SD_link_create(void *surf_link, void *data) { link = xbt_new(s_SD_link_t, 1); link->surf_link = surf_link; - link->data = data; /* user data */ + link->data = data; /* user data */ + if (surf_workstation_model->extension.workstation.link_shared(surf_link)) + link->sharing_policy = SD_LINK_SHARED; + else + link->sharing_policy = SD_LINK_FATPIPE; name = SD_link_get_name(link); - xbt_dict_set(sd_global->links, name, link, __SD_link_destroy); /* add the link to the dictionary */ + xbt_dict_set(sd_global->links, name, link, __SD_link_destroy); /* add the link to the dictionary */ sd_global->link_count++; return link; } + /** * \brief Returns the link list * @@ -32,19 +44,20 @@ SD_link_t __SD_link_create(void *surf_link, void *data) { * \return an array of \ref SD_link_t containing all links * \see SD_link_get_number() */ -const SD_link_t* SD_link_get_list(void) { +const SD_link_t *SD_link_get_list(void) +{ xbt_dict_cursor_t cursor; char *key; void *data; int i; - + SD_CHECK_INIT_DONE(); xbt_assert0(SD_link_get_number() > 0, "There is no link!"); - if (sd_global->link_list == NULL) { /* this is the first time the function is called */ + if (sd_global->link_list == NULL) { /* this is the first time the function is called */ sd_global->link_list = xbt_new(SD_link_t, sd_global->link_count); - + i = 0; xbt_dict_foreach(sd_global->links, cursor, key, data) { sd_global->link_list[i++] = (SD_link_t) data; @@ -59,7 +72,8 @@ const SD_link_t* SD_link_get_list(void) { * \return the number of existing links * \see SD_link_get_list() */ -int SD_link_get_number(void) { +int SD_link_get_number(void) +{ SD_CHECK_INIT_DONE(); return sd_global->link_count; } @@ -71,7 +85,8 @@ int SD_link_get_number(void) { * \return the user data associated with this link (can be \c NULL) * \see SD_link_set_data() */ -void* SD_link_get_data(SD_link_t link) { +void *SD_link_get_data(SD_link_t link) +{ SD_CHECK_INIT_DONE(); xbt_assert0(link != NULL, "Invalid parameter"); return link->data; @@ -87,7 +102,8 @@ void* SD_link_get_data(SD_link_t link) { * \param data the new data you want to associate with this link * \see SD_link_get_data() */ -void SD_link_set_data(SD_link_t link, void *data) { +void SD_link_set_data(SD_link_t link, void *data) +{ SD_CHECK_INIT_DONE(); xbt_assert0(link != NULL, "Invalid parameter"); link->data = data; @@ -99,69 +115,63 @@ void SD_link_set_data(SD_link_t link, void *data) { * \param link a link * \return the name of this link (cannot be \c NULL) */ -const char* SD_link_get_name(SD_link_t link) { +const char *SD_link_get_name(SD_link_t link) +{ SD_CHECK_INIT_DONE(); xbt_assert0(link != NULL, "Invalid parameter"); - return surf_workstation_model->extension_public->get_link_name(link->surf_link); + return surf_resource_name(link->surf_link); } /** * \brief Returns the current bandwidth of a link * * \param link a link - * \return the current bandwidth of this link, in Flops + * \return the current bandwidth of this link, in bytes per second */ -double SD_link_get_current_bandwidth(SD_link_t link) { +double SD_link_get_current_bandwidth(SD_link_t link) +{ SD_CHECK_INIT_DONE(); xbt_assert0(link != NULL, "Invalid parameter"); - return surf_workstation_model->extension_public->get_link_bandwidth(link->surf_link); -} - -/** - * \brief Returns the value of a certain link property - * - * \param workstation a workstation - * \param name a property name - * \return value of a property - */ -const char* SD_link_get_property_value(SD_link_t link, char* name) -{ - return xbt_dict_get_or_null(SD_link_get_properties(link), name); + return surf_workstation_model->extension.workstation. + get_link_bandwidth(link->surf_link); } /** - * \brief Returns a xbt_dynar_t consisting of the list of properties assigned to a link + * \brief Returns the current latency of a link * * \param link a link - * \return the dictionary containing the properties associated with the link + * \return the current latency of this link, in seconds */ -xbt_dict_t SD_link_get_properties(SD_link_t link) +double SD_link_get_current_latency(SD_link_t link) { SD_CHECK_INIT_DONE(); - xbt_assert0((link != NULL), "Invalid parameters"); - - return (surf_workstation_model->common_public->get_properties(link->surf_link)); - + xbt_assert0(link != NULL, "Invalid parameter"); + return surf_workstation_model->extension.workstation. + get_link_latency(link->surf_link); } /** - * \brief Returns the current latency of a link + * \brief Returns the sharing policy of this workstation. * * \param link a link - * \return the current latency of this link, in seconds + * \return the sharing policyfor the flows going through this link: + * SD_LINK_SHARED or SD_LINK_FATPIPE + * */ -double SD_link_get_current_latency(SD_link_t link) { +e_SD_link_sharing_policy_t SD_link_get_sharing_policy(SD_link_t link) +{ SD_CHECK_INIT_DONE(); xbt_assert0(link != NULL, "Invalid parameter"); - return surf_workstation_model->extension_public->get_link_latency(link->surf_link); + return link->sharing_policy; } + /* Destroys a link. */ -void __SD_link_destroy(void *link) { +void __SD_link_destroy(void *link) +{ SD_CHECK_INIT_DONE(); xbt_assert0(link != NULL, "Invalid parameter"); /* link->surf_link is freed by surf_exit and link->data is freed by the user */ xbt_free(link); } -