X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/05ac94f042a0e8534114f7f31a40a36af730a680..967421ad9a8dcd567206f2c398a30c08c9507a81:/src/surf/storage.c diff --git a/src/surf/storage.c b/src/surf/storage.c index ff53f1c41a..7aed75ee22 100644 --- a/src/surf/storage.c +++ b/src/surf/storage.c @@ -37,7 +37,7 @@ static xbt_dynar_t storage_list; static xbt_dict_t parse_storage_content(char *filename, unsigned long *used_size); static void storage_action_state_set(surf_action_t action, e_surf_action_state_t state); -static surf_action_t storage_action_execute (void *storage, size_t size, e_surf_action_storage_type_t type); +static surf_action_t storage_action_execute (void *storage, double size, e_surf_action_storage_type_t type); static surf_action_t storage_action_stat(void *storage, surf_file_t stream) { @@ -66,7 +66,7 @@ static surf_action_t storage_action_open(void *storage, const char* mount, const static surf_action_t storage_action_close(void *storage, surf_file_t fp) { char *filename = fp->name; - XBT_DEBUG("\tClose file '%s' size '%ld'",filename,fp->content->stat.size); + XBT_DEBUG("\tClose file '%s' size '%f'",filename,fp->content->stat.size); free(fp->name); fp->content = NULL; xbt_free(fp); @@ -74,11 +74,9 @@ static surf_action_t storage_action_close(void *storage, surf_file_t fp) return action; } -static surf_action_t storage_action_read(void *storage, void* ptr, size_t size, size_t nmemb, surf_file_t stream) +static surf_action_t storage_action_read(void *storage, void* ptr, double size, size_t nmemb, surf_file_t stream) { - char *filename = stream->name; surf_stat_t content = stream->content; - XBT_DEBUG("\tRead file '%s' size '%zu/%zu'",filename,size,content->stat.size); if(size > content->stat.size) size = content->stat.size; surf_action_t action = storage_action_execute(storage,size,READ); @@ -89,7 +87,7 @@ static surf_action_t storage_action_write(void *storage, const void* ptr, size_t { char *filename = stream->name; surf_stat_t content = stream->content; - XBT_DEBUG("\tWrite file '%s' size '%zu/%zu'",filename,size,content->stat.size); + XBT_DEBUG("\tWrite file '%s' size '%zu/%f'",filename,size,content->stat.size); surf_action_t action = storage_action_execute(storage,size,WRITE); action->file = stream; @@ -101,12 +99,12 @@ static surf_action_t storage_action_write(void *storage, const void* ptr, size_t return action; } -static surf_action_t storage_action_execute (void *storage, size_t size, e_surf_action_storage_type_t type) +static surf_action_t storage_action_execute (void *storage, double size, e_surf_action_storage_type_t type) { surf_action_storage_t action = NULL; storage_t STORAGE = storage; - XBT_IN("(%s,%zu)", surf_resource_name(STORAGE), size); + XBT_IN("(%s,%f)", surf_resource_name(STORAGE), size); action = surf_action_new(sizeof(s_surf_action_storage_t), size, surf_storage_model, STORAGE->state_current != SURF_RESOURCE_ON); @@ -217,22 +215,27 @@ static void storage_update_actions_state(double now, double delta) } xbt_swag_foreach_safe(action, next_action, running_actions) { + double_update(&(GENERIC_ACTION(action).remains), lmm_variable_getvalue(GENERIC_LMM_ACTION(action).variable) * delta); + if (GENERIC_LMM_ACTION(action).generic_action.max_duration != NO_MAX_DURATION) double_update(&(GENERIC_ACTION(action).max_duration), delta); + if(GENERIC_ACTION(action).remains > 0 && lmm_get_variable_weight(GENERIC_LMM_ACTION(action).variable) > 0 && - ((storage_t)action->storage)->used_size == ((storage_t)action->storage)->size) { + ((storage_t)action->storage)->used_size == ((storage_t)action->storage)->size) + { GENERIC_ACTION(action).finish = surf_get_clock(); storage_action_state_set((surf_action_t) action, SURF_ACTION_FAILED); - } else - if ((GENERIC_ACTION(action).remains <= 0) && - (lmm_get_variable_weight(GENERIC_LMM_ACTION(action).variable) > 0)) { + } else if ((GENERIC_ACTION(action).remains <= 0) && + (lmm_get_variable_weight(GENERIC_LMM_ACTION(action).variable) > 0)) + { GENERIC_ACTION(action).finish = surf_get_clock(); storage_action_state_set((surf_action_t) action, SURF_ACTION_DONE); } else if ((GENERIC_ACTION(action).max_duration != NO_MAX_DURATION) && - (GENERIC_ACTION(action).max_duration <= 0)) { + (GENERIC_ACTION(action).max_duration <= 0)) + { GENERIC_ACTION(action).finish = surf_get_clock(); storage_action_state_set((surf_action_t) action, SURF_ACTION_DONE); } @@ -496,7 +499,7 @@ static xbt_dict_t parse_storage_content(char *filename, unsigned long *used_size char time[12]; char path[1024]; int nb; - long size; + unsigned long size; surf_stat_t content;