- control_string = control_string_sav = strdup(str);
- control_string += strspn(control_string, " ");
- name = control_string;
- control_string += strcspn(str, ":=");
- value = control_string;
- *value=0;
- value++;
-
- xbt_assert1(strlen(name)!=0, "Invalid name for configuration: '%s'",name);
- xbt_assert1(strlen(value)!=0, "Invalid value for configuration: '%s'",value);
- INFO2("setting '%s' to '%s'",name,value);
-
- __simix_config_helper(name,value);
-
- free(control_string_sav);
- }
- xbt_dynar_free(&set_strings);
-}
-
-static void simix_cfg_init(int *argc,char **argv) {
- int i,j;
- char *opt;
-
- for (i=1; i<*argc; i++){
- if (!strncmp(argv[i],"--cfg=",strlen("--cfg="))) {
- opt=strchr(argv[i],'=');
- opt++;
-
- simix_cfg_control_set(opt);
- DEBUG1("Did apply '%s' as config setting",opt);
- /*remove this from argv*/
-
- for (j=i+1; j<*argc; j++){
- argv[j-1] = argv[j];
- }
-
- argv[j-1] = NULL;
- (*argc)--;
- i--; /* compensate effect of next loop incrementation */
- }
- }
-}
-
-/**
- * \brief Initialize some SIMIX internal data.
- *
- * \param argc Argc
- * \param argv Argv
- */
-void SIMIX_global_init(int *argc, char **argv)
-{
- s_smx_process_t proc;
-
- if (!simix_global) {
- surf_init(argc, argv); /* Initialize some common structures. Warning, it sets simix_global=NULL */
- simix_cfg_init(argc,argv);
-
- simix_global = xbt_new0(s_SIMIX_Global_t,1);
-
- simix_global->host = xbt_fifo_new();
- simix_global->process_to_run = xbt_swag_new(xbt_swag_offset(proc,synchro_hookup));
- simix_global->process_list = xbt_swag_new(xbt_swag_offset(proc,process_hookup));
- simix_global->current_process = NULL;
- simix_global->registered_functions = xbt_dict_new();
-
- simix_global->create_process_function = NULL;
- simix_global->kill_process_function = NULL;
- simix_global->cleanup_process_function = SIMIX_process_cleanup;
- }
-}
-
-/* Debug purpose, incomplete */
-void SIMIX_display_process_status(void)
-{
- smx_process_t process = NULL;
- xbt_fifo_item_t item = NULL;
- smx_action_t act;
- int nbprocess=xbt_swag_size(simix_global->process_list);
-
- INFO1("%d processes are still running, waiting for something.",
- nbprocess);
- /* List the process and their state */
- INFO0("Legend of the following listing: \"<process> on <host>: <status>.\"");
- xbt_swag_foreach(process, simix_global->process_list) {
- smx_simdata_process_t p_simdata = (smx_simdata_process_t) process->simdata;
- // simdata_host_t h_simdata=(simdata_host_t)p_simdata->host->simdata;
- char *who, *who2;
-
- asprintf(&who,"%s on %s: %s",
- process->name,
- p_simdata->s_host->name,
- (process->simdata->blocked)?"[BLOCKED] "
- :((process->simdata->suspended)?"[SUSPENDED] ":""));
-
- if (p_simdata->mutex) {
- who2=bprintf("%s Blocked on mutex %p",who,p_simdata->mutex);
- free(who); who=who2;
- } else if (p_simdata->cond) {
- who2=bprintf("%s Blocked on condition %p; Waiting for the following actions:",who,p_simdata->cond);
- free(who); who=who2;
- xbt_fifo_foreach(p_simdata->cond->actions,item, act, smx_action_t) {
- who2=bprintf("%s '%s'",who,act->name);
- free(who); who=who2;
- }
- } else {
- who2=bprintf("%s Blocked in an unknown status (please report this bug)",who);
- free(who); who=who2;
- }
- INFO1("%s.",who);
- free(who);
- }
-}