3 /* msg_config.c - support for MSG user configuration */
5 /* Copyright (c) 2005 Martin Quinson. */
6 /* All rights reserved. */
8 /* This program is free software; you can redistribute it and/or modify it
9 * under the terms of the license (GNU LGPL) which comes with this package. */
12 #include "xbt/sysdep.h"
15 int _msg_init_status = 0; /* 0: beginning of time;
16 1: pre-inited (cfg_set created);
17 2: inited (running) */
18 xbt_cfg_t _msg_cfg_set = NULL;
20 /* callback of the surf_workstation_model variable */
21 static void _msg_cfg_cb__surf_workstation_model(const char *name, int pos) {
24 xbt_assert0(_msg_init_status<2, "Cannot change the model after the initialization");
26 val = xbt_cfg_get_string (_msg_cfg_set, name);
28 xbt_assert1(!strcmp(val, "CLM03") ||
29 !strcmp(val, "KCCFLN05"),
30 "Unknown workstation model: %s (either 'CLM03' or 'KCCFLN05'",val);
33 /* create the config set and register what should be */
34 void msg_config_init(void) {
37 return; /* Already inited, nothing to do */
40 _msg_cfg_set = xbt_cfg_new();
42 xbt_cfg_register (_msg_cfg_set,
43 "surf_workstation_model", xbt_cfgelm_string, 1,1,
44 &_msg_cfg_cb__surf_workstation_model,NULL);
46 xbt_cfg_set_string(_msg_cfg_set,"surf_workstation_model", "CLM03");
49 void msg_config_finalize(void) {
51 if (!_msg_init_status)
52 return; /* Not initialized yet. Nothing to do */
54 xbt_cfg_free(&_msg_cfg_set);
58 /** \brief set a configuration variable
60 * Currently existing configuation variable:
61 * - surf_workstation_model (string): Model of workstation to use.
62 * Possible values (defaults to "CLM03"):
63 * - "CLM03": realistic TCP behavior + basic CPU model (see [CML03 at CCGrid03])
64 * - "KCCFLN05": simple network model (no latency) but interference
65 * between computations and communications (UNSTABLE, DONT USE)
68 * MSG_config("surf_workstation_model","CLM03");
71 MSG_config(const char *name, ...) {
74 if (!_msg_init_status) {
77 /* xbt_cfg_dump("msg_cfg_set","",_msg_cfg_set);*/
79 xbt_cfg_set_vargs(_msg_cfg_set,name,pa);