Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Adding sdp.c and the bunch of modified Makefile.in... :(
[simgrid.git] / doc / FAQ.doc
1 /*! \page faq Frequently Asked Questions
2
3 \htmlinclude .FAQ.doc.toc
4
5 \section faq_installation Installing the SimGrid library
6
7 Many people have been asking me questions on how to use SimGrid. Quite
8 often, the questions were not really about SimGrid but on the
9 installation process. This section is intended to help people that are
10 not familiar with compiling C files under UNIX. If you follow these
11 instructions and still have some troubles, drop an e-mail to
12 <simgrid-user@lists.gforge.inria.fr>.
13
14 \subsection faq_compiling Compiling SimGrid from an archive
15
16 First of all, you need to download the latest version of SimGrid from 
17 <a href="http://gforge.inria.fr/frs/?group_id=12">here</a>.
18 Suppose you have uncompressed SimGrid in some temporary location of
19 your home directory (say <tt>/home/joe/tmp/simgrid-3.0.1 </tt>). The
20 simplest way to use SimGrid is to install it in your home
21 directory. Change your directory to
22 <tt>/home/joe/tmp/simgrid-3.0.1</tt> and type
23
24 \verbatim./configure --prefix=$HOME
25 make
26 make install
27 \endverbatim
28
29 If at some point, something fails, check the section "\ref
30 faq_compil_trouble". If it does not help, you can report this problem to the
31 list but, please, avoid sending a laconic mail like "There is a problem. Is it
32 okay?". Send the config.log file which is automatically generated by
33 configure. Try to capture both the standard output and the error output of the
34 <tt>make</tt> command with <tt>script</tt>. There is no way for us to help you
35 without the relevant bits of information.
36
37 Now, the following directory should have been created : 
38
39       \li <tt>/home/joe/doc/simgrid/html/</tt>
40       \li <tt>/home/joe/lib/</tt>
41       \li <tt>/home/joe/include/</tt>
42
43 SimGrid is not a binary, it is a library. Both a static and a dynamic
44 version are available. Here is what you can find if you try a <tt>ls
45 /home/joe/lib</tt>:
46
47 \verbatim libsimgrid.a libsimgrid.la libsimgrid.so libsimgrid.so.0 libsimgrid.so.0.0.1
48 \endverbatim
49
50 Thus, there is two ways to link your program with SimGrid:
51       \li Either you use the static version, e.g 
52 \verbatim gcc libsimgrid.a -o MainProgram MainProgram.c
53 \endverbatim
54           In this case, all the SimGrid functions are directly
55           included in <tt>MainProgram</tt> (hence a bigger binary).
56       \li Either you use the dynamic version (the preferred method)
57 \verbatim gcc -lsimgrid -o MainProgram MainProgram.c
58 \endverbatim
59           In this case, the SimGrid functions are not included in
60           <tt>MainProgram</tt> and you need to set your environment
61           variable in such a way that <tt>libsimgrid.so</tt> will be
62           found at runtime. This can be done by adding the following
63           line in your .bashrc (if you use bash and if you have
64           installed the SimGrid libraries in your home directory):
65 \verbatim export LD_LIBRARY_PATH=$HOME/lib/:$LD_LIBRARY_PATH
66 \endverbatim
67
68
69 \subsection faq_compiling_cvs Compiling SimGrid from the CVS
70
71 The project development takes place in the cvs, where all changes are
72 commited when they happen. Then every once in a while, we make sure that the
73 code quality meets our standard and release an archive from the code in the
74 CVS. We afterward go back to the development in the CVS. So, if you need a
75 recently added feature and can afford some little problem with the stability
76 of the lastest features, you may want to use the CVS version instead of a
77 released one.
78
79 For that, you first need to get the "simgrid" module from
80 <a href="http://gforge.inria.fr/scm/?group_id=12">here</a>. 
81
82 You won't find any <tt>configure</tt> and a few other things
83 (<tt>Makefile.in</tt>'s, documentation, ...) will be missing as well. The
84 reason for that is that all these files have to be regenerated using the
85 latest versions of <tt>autoconf</tt>, <tt>libtool</tt>, <tt>automake</tt>
86 (>1.9) and <tt>doxygen</tt> (>1.4). To generate the <tt>configure</tt> and
87 the <tt>Makefile.in</tt>'s, you just have to launch the <tt>bootstrap</tt>
88 command that resides in the top of the source tree. Then just follow the
89 instructions of Section \ref faq_compiling.
90
91 We insist on the fact that you really need the latest versions of
92 autoconf and automake. Doing this step on exotic architectures/systems
93 (i.e. anything different from a recent linux distribution) may be
94 ... uncertain. If you want to use the CVS version on another
95 architecture/system, you should do the previous steps on a perfectly
96 standard box, then do a <tt>make dist</tt> that will build you a
97 perfectly portable SimGrid archive.
98
99 In summary, the following commands will checkout the CVS, regenerate the
100 configure script and friends, configure SimGrid and build an archive you can
101 use on another machine afterward.
102
103 \verbatim cvs -d :pserver:anonymous@scm.gforge.inria.fr:/cvsroot/simgrid login
104 cvs -d :pserver:anonymous@scm.gforge.inria.fr:/cvsroot/simgrid checkout simgrid
105 cd simgrid
106 ./bootstrap
107 ./configure --enable-maintainer-mode
108 make dist \endverbatim
109
110 Moreover, you should never call the autotools manually since you must run
111 them in a specific order with specific arguments. Most of the times, the
112 makefiles will automatically call the tools for you. When it's not possible
113 (such as the first time you checkout the CVS), use the ./bootstrap command
114 to call them explicitely.
115
116 If you need to compile the CVS version on a machine where all these
117 dependencies are not met, the easiest is to do <tt>make dist</tt> in the CVS
118 dir, on another machine where all dependencies are met. It will create an
119 archive you may deploy on other sites just as a regular stable release.
120
121 \subsection faq_setting_MSG Setting up your own MSG code
122
123 Do not build your simulator by modifying the SimGrid examples.  Go
124 outside the SimGrid source tree and create your own working directory
125 (say <tt>/home/joe/SimGrid/MyFirstScheduler/</tt>).
126
127 Suppose your simulation has the following structure (remember it is
128 just an example to illustrate a possible way to compile everything;
129 feel free to organize it as you want).
130
131       \li <tt>sched.h</tt>: a description of the core of the
132           scheduler (i.e. which functions are can be used by the
133           agents). For example we could find the following functions
134           (master, forwarder, slave).
135
136       \li <tt>sched.c</tt>: a C file including <tt>sched.h</tt> and
137           implementing the core of the scheduler. Most of these
138           functions use the MSG functions defined in section \ref
139           msg_gos_functions.
140
141       \li <tt>masterslave.c</tt>: a C file with the main function, i.e.
142           the MSG initialization (MSG_global_init()), the platform
143           creation (e.g. with MSG_create_environment()), the
144           deployment phase (e.g. with MSG_function_register() and
145           MSG_launch_application()) and the call to
146           MSG_main()).
147
148 To compile such a program, we suggest to use the following
149 Makefile. It is a generic Makefile that we have used many times with
150 our students when we teach the C language.
151
152 \verbatim
153 all: masterslave 
154 masterslave: masterslave.o sched.o
155
156 INSTALL_PATH = $$HOME
157 CC = gcc
158 PEDANTIC_PARANOID_FREAK =       -O0 -Wshadow -Wcast-align \
159                                 -Waggregate-return -Wmissing-prototypes -Wmissing-declarations \
160                                 -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations \
161                                 -Wmissing-noreturn -Wredundant-decls -Wnested-externs \
162                                 -Wpointer-arith -Wwrite-strings -finline-functions
163 REASONABLY_CAREFUL_DUDE =       -Wall
164 NO_PRAYER_FOR_THE_WICKED =      -w -O2 
165 WARNINGS =                      $(REASONABLY_CAREFUL_DUDE)
166 CFLAGS = -g $(WARNINGS)
167
168 INCLUDES = -I$(INSTALL_PATH)/include
169 DEFS = -L$(INSTALL_PATH)/lib/
170 LDADD = -lm -lsimgrid 
171 LIBS = 
172
173 %: %.o
174         $(CC) $(INCLUDES) $(DEFS) $(CFLAGS) $^ $(LIBS) $(LDADD) -o $@ 
175
176 %.o: %.c
177         $(CC) $(INCLUDES) $(DEFS) $(CFLAGS) -c -o $@ $<
178
179 clean:
180         rm -f $(BIN_FILES) *.o *~
181 .SUFFIXES:
182 .PHONY : clean
183
184 \endverbatim
185
186 The first two lines indicates what should be build when typing make
187 (<tt>masterslave</tt>) and of which files it is to be made of
188 (<tt>masterslave.o</tt> and <tt>sched.o</tt>). This makefile assumes
189 that you have set up correctly your <tt>LD_LIBRARY_PATH</tt> variable
190 (look, there is a <tt>LDADD = -lm -lsimgrid</tt>). If you prefer using
191 the static version, remove the <tt>-lsimgrid</tt> and add a
192 <tt>$(INSTALL_PATH)/lib/libsimgrid.a</tt> on the next line, right
193 after the <tt>LIBS = </tt>.
194
195 More generally, if you have never written a Makefile by yourself, type
196 in a terminal : <tt>info make</tt> and read the introduction. The
197 previous example should be enough for a first try but you may want to
198 perform some more complex compilations...
199
200 \subsection faq_setting_GRAS Setting up your own GRAS code
201
202 If you use the GRAS interface instead of the MSG one, then previous section
203 is not the better source of information. Instead, you should check the GRAS
204 tutorial in general, and the \ref GRAS_tut_tour_setup in particular.
205
206 \subsection faq_crosscompile Cross-compiling a Windows DLL of SimGrid from linux
207
208 At the moment, we do not distribute Windows pre-compiled version of SimGrid
209 because the support for this platform is still experimental. We know that
210 some parts of the GRAS environment do not work, and we think that the others
211 environments (MSG and SD) have good chances to work, but we didn't test
212 ourselves. This section explains how we generate the SimGrid DLL so that you
213 can build it for yourself. First of all, you need to have a version more
214 recent than 3.1 (ie, a CVS version as time of writting).
215
216 In order to cross-compile the package to windows from linux, you need to
217 install mingw32 (minimalist gnu win32). On Debian, you can do so by
218 installing the packages mingw32 (compiler), mingw32-binutils (linker and
219 so), mingw32-runtime.
220
221 You can use the VPATH support of configure to compile at the same time for
222 linux and windows without dupplicating the source nor cleaning the tree
223 between each. Just run bootstrap (if you use the CVS) to run the autotools.
224 Then, create a linux and a win directories. Then, type:
225 \verbatim  cd linux; ../configure --srcdir=.. <usual configure flags>; make; cd ..
226 cd win;  ../configure --srcdir=.. --host=i586-mingw32msvc <flags>; make; cd ..
227 \endverbatim
228 The trick to VPATH builds is to call configure from another directory,
229 passing it an extra --srcdir argument to tell it where all the sources are.
230 It will understand you want to use VPATH. Then, the trick to cross-compile
231 is simply to add a --host argument specifying the target you want to build
232 for. The i586-mingw32msvc string is what you have to pass to use the mingw32
233 environment as distributed in Debian.
234
235 After that, you can run all make targets from both directories, and test
236 easily that what you change for one arch does not break the other one. 
237
238 It is possible that this VPATH build thing breaks from time to time in the
239 CVS since it's quite fragile, but it's granted to work in any released
240 version. If you experience problems, drop us a mail. 
241
242 Another possible source of issue is that at the moment, building the
243 examples request to use the gras_stub_generator tool, which is a compiled
244 program, not a script. In cross-compilation, you need to cross-execute with
245 wine for example, which is not really pleasant. We are working on this, but
246 in the meanwhile, simply don't build the examples in cross-compilation
247 (<tt>cd src</tt> before running make).
248     
249 Program (cross-)compiled with mingw32 do request an extra DLL at run-time to be
250 usable. For example, if you want to test your build with wine, you should do
251 the following to put this library where wine looks for DLLs.
252 \verbatim 
253 cp /usr/share/doc/mingw32-runtime/mingwm10.dll.gz ~/.wine/c/windows/system/
254 gunzip ~/.wine/c/windows/system/mingwm10.dll.gz
255 \endverbatim
256
257 The DLL is builded in src/.libs, and installed in the <i>prefix</i>/bin directory
258 when you run make install. 
259
260 If you want to use it in a native project on windows, you need to use 
261 simgrid.dll and mingwm10.dll. For each DLL, you need to build .def file
262 under linux (listing the defined symbols), and convert it into a .lib file
263 under windows (specifying this in a way that windows compilers like). To
264 generate the def files, run (under linux):
265 \verbatim echo "LIBRARY libsimgrid-0.dll" > simgrid.def
266 echo EXPORTS >> simgrid.def
267 nm libsimgrid-0.dll | grep ' T _' | sed 's/.* T _//' >> simgrid.def
268 nm libsimgrid-0.dll | grep ' D _' | sed 's/.* D _//' | sed 's/$/ DATA/' >> simgrid.def
269
270 echo "LIBRARY mingwm10.dll" > mingwm10.def
271 echo EXPORTS >> mingwm10.def
272 nm mingwm10.dll | grep ' T _' | sed 's/.* T _//' >> mingwm10.def
273 nm mingwm10.dll | grep ' D _' | sed 's/.* D _//' | sed 's/$/ DATA/' >> mingwm10.def
274 \endverbatim
275
276 To create the import .lib files, use the <tt>lib</tt> windows tool (from
277 MSVC) the following way to produce simgrid.lib and mingwm10.lib
278 \verbatim lib /def:simgrid.def
279 lib /def:mingwm10.def
280 \endverbatim
281
282 If you happen to use Borland C Builder, the right command line is the
283 following (note that you don't need any file.def to get this working).
284 \verbatim implib simgrid.lib libsimgrid-0.dll
285 implib mingwm10.lib mingwm10.dll
286 \endverbatim
287
288 Then, set the following parameters in Visual C++ 2005:
289 Linker -> Input -> Additional dependencies = simgrid.lib mingwm10.lib
290
291 Just in case you wonder how to generate a DLL from libtool in another
292 project, we added -no-undefined to any lib*_la_LDFLAGS variables so that
293 libtool accepts to generate a dynamic library under windows. Then, to make
294 it true, we pass any dependencies (such as -lws2 under windows or -lpthread
295 on need) on the linking line. Passing such deps is a good idea anyway so
296 that they get noted in the library itself, avoiding the users to know about
297 our dependencies and put them manually on their compilation line. Then we
298 added the AC_LIBTOOL_WIN32_DLL macro just before AC_PROG_LIBTOOL in the
299 configure.ac. It means that we exported any symbols which need to be.
300 Nowadays, functions get automatically exported, so we don't need to load our
301 header files with tons of __declspec(dllexport) cruft. We only need to do so
302 for data, but there is no public data in SimGrid so we are good.
303
304 \section faq_simgrid I'm new to SimGrid. I have some questions. Where should I start?
305
306 You are at the right place... Having a look to these
307 <a href="http://graal.ens-lyon.fr/~alegrand/articles/slides_g5k_simul.pdf">slides</a>
308 (or to these
309 <a href="http://graal.ens-lyon.fr/~alegrand/articles/Simgrid-Introduction.pdf">"obsolete" slides</a>)
310 may give you some insights on what SimGrid can help you to do and what
311 are its limitations. Then you definitely should read the \ref
312 MSG_examples. There is also a mailing list: <simgrid-user@lists.gforge.inria.fr>.
313
314 \subsection faq_generic Building a generic simulator
315
316 Please read carefully the \ref MSG_examples. You'll find in \ref
317 MSG_ex_master_slave a very simple consisting of a master (that owns a bunch of
318 tasks and distributes them) , some slaves (that process tasks whenever
319 they receive one) and some forwarder agents (that simply pass the
320 tasks they receive to some slaves).
321
322 \subsection faq_visualization Visualizing the schedule
323
324 It is sometime convenient to "see" how the agents are behaving. If you
325 like colors, you can use <tt>tools/MSG_visualization/colorize.pl </tt>
326 as a filter to your MSG outputs. It works directly with INFO. Beware,
327 INFO() prints on stderr. Do not forget to redirect if you want to
328 filter (e.g. with bash): 
329 \verbatim 
330 ./msg_test small_platform.xml small_deployment.xml 2>&1 | ../../tools/MSG_visualization/colorize.pl
331 \endverbatim
332
333 We also have a more graphical output. Have a look at MSG_paje_output(). It 
334 generates an input to <a href="http://www-id.imag.fr/Logiciels/paje/">Paje</a>.
335 <center>
336 \htmlonly
337  <a href="Paje_MSG_screenshot.jpg"><img src="Paje_MSG_screenshot_thn.jpg"></a>
338 \endhtmlonly
339 </center>
340
341 \subsection faq_postmortem_analysis Online/postmortem analysis
342
343 Vizualization with Paje can be seen as a kind of postmortem
344 analysis. However, as soon as you start playing with big simulations,
345 you'll realize that processing such output is kind of tricky. There is
346 so much generic informations that it is hard to find the information
347 you are looking for.
348
349 As a matter of fact, loging really depends on simulations (e.g. what
350 kind of events is important...). That is why we do not propose a big
351 dump of your whole simulation (it would slow everything down) but give
352 you neat tools to structure you logs. Have a look at \ref XBT_log. In
353 fact, rather than a post-mortem analysis, you may want to do it on the
354 fly. The process you are running can do whatever you want. Have you
355 thought about adding a global structure where you directly compute the
356 informations that are really important rather than writing everything
357 down and then processing huge files ?
358
359 \subsection faq_C Argh! Do I really have to code in C ?
360
361 Up until now, there is no binding for other languages. If you use C++,
362 you should be able to use the SimGrid library as a standard C library
363 and everything should work fine (simply <i>link</i> against this
364 library; recompiling SimGrid with a C++ compiler won't work and it
365 wouldn't help if you could).
366
367 In fact, the bindings needed to allow one to use SimGrid from Perl,
368 Python, Java, etc. are double-layered.  The first layer would allow
369 you to call for example the MSG_task_get_name(task) function while
370 what you really want is a proper object wrapping allowing you to call
371 task->name(). That's the purpose of the second layer.  The first one
372 is granted with C++ but can be done with tools like 
373 <a href="www.swig.org/">swig</a> for other languages like Perl, Ruby,
374 Python, CAML. None of us really need the second one (which is a bit
375 more demanding and cannot be automatically generated) yet and there is
376 no real point in doing the first one without the second. :)
377
378 As usual, you're welcome to participate.
379
380 \section faq_MIA How to ....? Is there a function in the API to simply ....?
381
382 Here is the deal. The whole SimGrid project (MSG, SURF, GRAS, ...) is
383 meant to be kept as simple and generic as possible. We cannot add
384 functions for everybody's need when these functions can easily be
385 built from the ones already in the API. Most of the time, it is
386 possible and when it was not possible we always have upgraded the API
387 accordingly. When somebody asks us a question like "How to do that ?
388 Is there a function in the API to simply do this ?", we're always glad
389 to answer and help. However if we don't need this code for our own
390 need, there is no chance we're going to write it... it's your job! :)
391 The counterpart to our answers is that once you come up with a neat
392 implementation of this feature (task duplication, RPC, thread
393 synchronization, ...), you should send it to us and we will be glad to
394 add it to the distribution. Thus, other people will take advantage of
395 it (and we don't have to answer this question again and again ;).
396
397 You'll find in this section a few "Missing In Action" features. Many
398 people have asked about it and we have given hints on how to simply do
399 it with MSG. Feel free to contribute...
400
401 \subsection faq_MIA_examples I want some more complex examples!
402
403 Many people have come to ask me a more complex example and each time,
404 they have realized afterward that the basics were in the previous three
405 examples. 
406
407 Of course they have often been needing more complex functions like
408 MSG_process_suspend(), MSG_process_resume() and
409 MSG_process_isSuspended() (to perform synchronization), or
410 MSG_task_Iprobe() and MSG_process_sleep() (to avoid blocking
411 receptions), or even MSG_process_create() (to design asynchronous
412 communications or computations). But the examples are sufficient to
413 start.
414
415 We know. We should add some more examples, but not really some more
416 complex ones... We should add some examples that illustrate some other
417 functionalities (like how to simply encode asynchronous
418 communications, RPC, process migrations, thread synchronization, ...)
419 and we will do it when we will have a little bit more time. We have
420 tried to document the examples so that they are understandable. Tell
421 us if something is not clear and once again feel free to participate!
422 :)
423
424 \subsection faq_MIA_taskdup Missing in action: Task duplication/replication
425
426 There is no task duplication in MSG. When you create a task, you can
427 process it or send it somewhere else. As soon as a process has sent
428 this task, he doesn't have this task anymore. It's gone. The receiver
429 process has got the task. However, you could decide upon receiving to
430 create a "copy" of a task but you have to handle by yourself the
431 semantic associated to this "duplication".
432
433 As we already told, we prefer keeping the API as simple as
434 possible. This kind of feature is rather easy to implement by users
435 and the semantic you associate really depends on people. Having a
436 *generic* task duplication mechanism is not that trivial (in
437 particular because of the data field). That is why I would recommand
438 that you write it by yourself even if I can give you advice on how to
439 do it.
440
441 You have the following functions to get informations about a task:
442 MSG_task_get_name(), MSG_task_get_compute_duration(),
443 MSG_task_get_remaining_computation(), MSG_task_get_data_size(),
444 and MSG_task_get_data().
445
446 You could use a dictionnary (#xbt_dict_t) of dynars (#xbt_dynar_t). If
447 you still don't see how to do it, please come back to us...
448
449 \subsection faq_MIA_asynchronous I want to do asynchronous communications in MSG
450
451 Up until now, there is no asynchronous communications in MSG. However,
452 you can create as many process as you want so you should be able to do
453 whatever you want... I've written a queue module to help implementing
454 some asynchronous communications at low cost (creating thousands of
455 process only to handle communications may be problematic in term of
456 performance at some point). I'll add it in the distribution asap.
457
458 \subsection faq_MIA_thread_synchronization I need to synchronize my MSG processes
459
460 You obviously cannot use pthread_mutexes of pthread_conds. The best
461 thing would be to propose similar structures. Unfortunately, we
462 haven't found time to do it yet. However you can try to play with
463 MSG_process_suspend() and MSG_process_resume(). You can even do some
464 synchronization with fake communications (using MSG_task_get(),
465 MSG_task_put() and MSG_task_Iprobe()).
466
467 \subsection faq_MIA_host_load Where is the get_host_load function hidden in MSG?
468
469 There is no such thing because its semantic wouldn't be really
470 clear. Of course, it is something about the amount of host throughput,
471 but there is as many definition of "host load" as people asking for
472 this function. First, you have to remember that resource availability
473 may vary over time, which make any load notion harder to define.
474
475 It may be instantaneous value or an average one. Moreover it may be only the
476 power of the computer, or may take the background load into account, or may
477 even take the currently running tasks into account. In some SURF models,
478 communications have an influence on computational power. Should it be taken
479 into account too?
480
481 So, we decided not to include such a function into MSG and let people do it
482 thereselves so that they get the value matching exactly what they mean. One
483 possibility is to run active measurement as in next code snippet. It is very
484 close from what you would have to do out of the simulator, and thus gives
485 you information that you could also get in real settings to not hinder the
486 realism of your simulation. 
487
488 \verbatim
489 double get_host_load() {
490    m_task_t task = MSG_task_create("test", 0.001, 0, NULL);
491    double date = MSG_get_clock();
492
493    MSG_task_execute(task);
494    date = MSG_get_clock() - date;
495    MSG_task_destroy(task);
496    return (0.001/date);
497 }
498 \endverbatim
499
500 Of course, it may not match your personal definition of "host load". In this
501 case, please detail what you mean on the mailing list, and we will extend
502 this FAQ section to fit your taste if possible.
503
504 \subsection faq_MIA_communication_time How can I get the *real* communication time ?  
505
506 Communications are synchronous and thus if you simply get the time
507 before and after a communication, you'll only get the transmission
508 time and the time spent to really communicate (it will also take into
509 account the time spent waiting for the other party to be
510 ready). However, getting the *real* communication time is not really
511 hard either. The following solution is a good starting point.
512
513 \verbatim
514 int sender()
515 {
516   m_task_t task = MSG_task_create("Task", task_comp_size, task_comm_size, 
517                                   calloc(1,sizeof(double)));
518   *((double*) task->data) = MSG_get_clock();
519   MSG_task_put(task, slaves[i % slaves_count], PORT_22);
520   INFO0("Send completed");
521   return 0;
522 }
523 int receiver()
524 {
525   m_task_t task = NULL;
526   double time1,time2;
527
528   time1 = MSG_get_clock();
529   a = MSG_task_get(&(task), PORT_22);
530   time2 = MSG_get_clock();
531   if(time1<*((double *)task->data))
532      time1 = *((double *) task->data);
533   INFO1("Communication time :  \"%f\" ", time2-time1);
534   free(task->data);
535   MSG_task_destroy(task);
536   return 0;
537 }
538 \endverbatim
539
540 \subsection faq_MIA_batch_scheduler Is there a native support for batch schedulers in SimGrid ?
541
542 No, there is no native support for batch schedulers and none is
543 planned because this is a very specific need (and doing it in a
544 generic way is thus very hard). However some people have implemented
545 their own batch schedulers. Vincent Garonne wrote one during his PhD
546 and put his code in the contrib directory of our CVS so that other can
547 keep working on it. You may find inspinring ideas in it.
548
549 \subsection faq_MIA_checkpointing I need a checkpointing thing
550
551 Actually, it depends on whether you want to checkpoint the simulation, or to
552 simulate checkpoints. 
553
554 The first one could help if your simulation is a long standing process you
555 want to keep running even on hardware issues. It could also help to
556 <i>rewind</i> the simulation by jumping sometimes on an old checkpoint to
557 cancel recent calculations.\n 
558 Unfortunately, such thing will probably never exist in SG. One would have to
559 duplicate all data structures because doing a rewind at the simulator level
560 is very very hard (not talking about the malloc free operations that might
561 have been done in between). Instead, you may be interested in the Libckpt
562 library (http://www.cs.utk.edu/~plank/plank/www/libckpt.html). This is the
563 checkpointing solution used in the condor project, for example. It makes it
564 easy to create checkpoints (at the OS level, creating something like core
565 files), and rerunning them on need.
566
567 If you want to simulate checkpoints instead, it means that you want the
568 state of an executing task (in particular, the progress made towards
569 completion) to be saved somewhere.  So if a host (and the task executing on
570 it) fails (cf. #MSG_HOST_FAILURE), then the task can be restarted
571 from the last checkpoint.\n
572
573 Actually, such a thing does not exists in SimGrid either, but it's just
574 because we don't think it is fundamental and it may be done in the user code
575 at relatively low cost. You could for example use a watcher that
576 periodically get the remaining amount of things to do (using
577 MSG_task_get_remaining_computation()), or fragment the task in smaller
578 subtasks.
579
580 \section faq_SG Where has SG disappeared?!?
581
582 OK, it's time to explain what's happening to the SimGrid project. Let's
583 start with a little bit of history.
584
585 * Historically, SimGrid was a low-level toolkit for scheduling with
586 classical models such as DAGs. That was SimGrid v.1.* aka SG, written
587 by Henri Casanova. I (Arnaud) had been using it in its earliest
588 versions during an internship at UCSD.
589
590 Then we have realized that encoding distributed algorithm in SG was a
591 real pain.
592
593 * So we have built MSG on top of SG and have released SimGrid v.2.*. MSG
594 offered a very basic API to encode a distributed application easily.
595 However encoding MSG on top of SG was not really convenient and did not
596 use the DAG part since the control of the task synchronization was done
597 on top of MSG and no more in SG. We have been playing a little bit with
598 MSG. We have realized that:
599
600    \li 1) the platform modeling was quite flexible and could be "almost"
601        automated (e.g. using random generator and post-annotations);
602
603    \li 2) SG was the bottleneck because of the way we were using
604        it. We needed to simulate concurrent transfers, complex load
605        sharing mechanisms. Many optimizations (e.g. trace integration)
606        were totally inefficient when combined with MSG and made extending SG
607        to implement new sharing policies, parallel tasks models, or failures
608        (many people were asking for these kind of features) a real pain;
609
610    \li 3) the application modeling was not really easy. Even though the
611        application modeling depends on people's applications, we thought
612        we could improve things here. One of our target here was realistic
613 distributed applications ranging from computer sensor networks like
614 the NWS to peer-to-peer applications;
615
616 * So we have been planning mainly two things for SimGrid 3:
617
618    \li 1) I have proposed to get rid of SG and to re-implement a new kernel
619        that would be faster and more flexible. That is what I did in the
620 end of 2004: SURF. SURF is based on a fast max-min linear solver
621 using O(1) data-structures. I have quickly replaced SG by SURF in
622 MSG and the result has been that on the MSG example, the new
623 version was more than 10 times faster while we had gain a lot of
624 flexibility. I think I could still easily make MSG faster but I
625 have to work on MSG now (e.g. using some of the O(1)
626 data-structures I've been using to build SURF) since it has become
627 the bottleneck. Some MSG functions have been removed from the API
628 but they were mainly intended to build the platform by hand (they
629 had appeared in the earliest versions of MSG) and were therefore
630 not useful anymore since we are providing a complete mechanism to
631 automatically build the platform and deploy the agents on it.;
632
633    \li 2) GRAS is a new project Martin and I have come up with. The idea is
634 to have a programming environment that let you program real
635 distributed applications while letting you the ability to run it in
636 the simulator without having to change the slightest line of your
637 code. From the simulation point of view, GRAS performs the
638 application modeling automatically... Up until now, GRAS works on
639 top MSG for historical reasons but I'm going to make it work
640 directly on top of SURF so that it can use all the flex and the
641 speed provided by SURF.
642
643 Those two things are working, but we want to make everything as clean as
644 possible before releasing SimGrid v.3.
645
646 So what about those nice DAGs we used to have in SimGrid v.1.? They're
647 not anymore in SimGrid v.3. At least not in their original form... Let
648 me recall you the way SimGrid 3 is organized:
649
650 \verbatim
651 ________________
652 |   User code  |
653 |______________|
654 | | MSG | GRAS |
655 | -------------|
656 | |   SURF     |
657 | -------------|
658 |     XBT      |
659 ----------------
660 \endverbatim
661
662 XBT is our tool box and now, you should have an idea of what the other
663 ones are. As you can see, the primitive SG is not here
664 anymore. However we have written a brand new and cleaner API for this
665 purpose: \ref SD_API. It is built directly on top of SURF and provides
666 an API rather close to the old SG:
667
668 \verbatim
669 ______________________
670 |    User code       |
671 |____________________|
672 | | MSG | GRAS | SD  |
673 | -------------------|
674 | |      SURF        |
675 | -------------------|
676 |        XBT         |
677 ----------------------
678 \endverbatim
679
680 The nice thing is that, as it is writen on top of SURF, it seamlessly
681 support DAG of parallel tasks as well as complex communications
682 patterns. Some old codes using SG are currently under rewrite using
683 \ref SD_API to check that all needful functions are provided.
684
685 \subsection faq_SG_DAG How to implement a distributed dynamic scheduler of DAGs.
686
687 Distributed is somehow "contagious". If you start making distributed
688 decisions, there is no way to handle DAGs directly anymore (unless I
689 am missing something). You have to encode your DAGs in term of
690 communicating process to make the whole scheduling process
691 distributed. Here is an example of how you could do that. Assume T1
692 has to be done before T2.
693
694 \verbatim
695  int your_agent(int argc, char *argv[] {
696    ...
697    T1 = MSG_task_create(...);
698    T2 = MSG_task_create(...);
699    ...
700    while(1) {
701      ...
702      if(cond) MSG_task_execute(T1);
703      ...
704      if((MSG_task_get_remaining_computation(T1)=0.0) && (you_re_in_a_good_mood))
705         MSG_task_execute(T2)
706      else {
707         /* do something else */
708      }
709    }
710  }
711 \endverbatim
712  
713 If you decide that the distributed part is not that much important and that
714 DAG is really the level of abstraction you want to work with, then you should
715 give a try to \ref SD_API.
716
717 \section faq_dynamic Dynamic resources and platform building
718
719 \subsection faq_platform Building a realistic platform
720
721 We can speak more than an hour on this subject and we still do not have
722 the right answer, just some ideas. You can read the following
723 <a href="http://graal.ens-lyon.fr/~alegrand/articles/Simgrid-Introduction.pdf">slides</a>.
724 It may give you some hints. You can also have a look at the
725 <tt>tools/platform_generation/</tt> directory. There is a perl-script
726 we use to annotate a Tiers generated platform.
727
728 \subsection faq_SURF_dynamic How can I have variable resource availability?
729
730 A nice feature of SimGrid is that it enables you to seamlessly have
731 resources whose availability change over time. When you build a
732 platform, you generally declare CPUs like that:
733
734 \verbatim
735   <cpu name="Cpu A" power="100.00"/>
736 \endverbatim 
737
738 If you want the availability of "CPU A" to change over time, the only
739 thing you have to do is change this definition like that:
740
741 \verbatim
742   <cpu name="Cpu A" power="100.00" availability_file="trace_A.txt" state_file="trace_A_failure.txt"/>
743 \endverbatim
744
745 For CPUs, availability files are expressed in fraction of available
746 power. Let's have a look at what "trace_A.txt" may look like:
747
748 \verbatim
749 PERIODICITY 1.0
750 0.0 1.0
751 11.0 0.5
752 20.0 0.9
753 \endverbatim
754
755 At time 0, our CPU will deliver 100 Mflop/s. At time 11.0, it will
756 deliver only 50 Mflop/s until time 20.0 where it will will start
757 delivering 90 Mflop/s. Last at time 21.0 (20.0 plus the periodicity
758 1.0), we'll be back to the beginning and it will deliver 100Mflop/s.
759
760 Now let's look at the state file:
761 \verbatim
762 PERIODICITY 10.0
763 1.0 -1.0
764 2.0 1.0
765 \endverbatim
766
767 A negative value means "off" while a positive one means "on". At time
768 1.0, the CPU is on. At time 1.0, it is turned off and at time 2.0, it
769 is turned on again until time 12 (2.0 plus the periodicity 10.0). It
770 will be turned on again at time 13.0 until time 23.0, and so on.
771
772 Now, let's look how the same kind of thing can be done for network
773 links. A usual declaration looks like:
774
775 \verbatim
776   <network_link name="LinkA" bandwidth="10.0" latency="0.2"/>
777 \endverbatim
778
779 You have at your disposal the following options: bandwidth_file,
780 latency_file and state_file. The only difference with CPUs is that
781 bandwidth_file and latency_file do not express fraction of available
782 power but are expressed directly in Mb/s and seconds.
783
784 \subsection faq_flexml_bypassing How can I have some C functions do what the platform file does?
785
786 So you want to bypass the XML files parser, uh? Maybe doin some parameter
787 sweep experiments on your simulations or so? This is possible, but it's not
788 really easy. Here is how it goes.
789
790 For this, you have to first remember that the XML parsing in SimGrid is done
791 using a tool called FleXML. Given a DTD, this gives a flex-based parser. If
792 you want to bypass the parser, you need to provide some code mimicking what
793 it does and replacing it in its interactions with the SURF code. So, let's
794 have a look at these interactions.
795
796 FleXML parser are close to classical SAX parsers. It means that a
797 well-formed SimGrid platform XML file might result in the following
798 "events":
799
800   - start "platform_description"
801   - start "cpu" with attributes name="host1" power="1.0"
802   - end "cpu"
803   - start "cpu" with attributes name="host2" power="2.0"
804   - end "cpu"
805   - start "network_link" with ...
806   - end "network_link"
807   - start "route" with ...
808   - end "route"
809   - start "route" with ...
810   - end "route"
811   - end "platform_description"
812
813 The communication from the parser to the SURF code uses two means:
814 Attributes get copied into some global variables, and a surf-provided
815 function gets called by the parser for each event. For example, the event
816   - start "cpu" with attributes name="host1" power="1.0"
817
818 let the parser do the equivalent of:
819 \verbatim
820   strcpy("host1",A_cpu_name);
821   A_cpu_power = 1.0;
822   (*STag_cpu_fun)();
823 \endverbatim
824
825 In SURF, we attach callbacks to the different events by initializing the
826 pointer functions to some the right surf functions. Example in
827 workstation_KCCFLN05.c (surf_parse_open() ends up calling surf_parse()):
828 \verbatim
829   // Building the routes
830   surf_parse_reset_parser();
831   STag_route_fun=parse_route_set_endpoints;
832   ETag_route_element_fun=parse_route_elem;
833   ETag_route_fun=parse_route_set_route;
834   surf_parse_open(file);
835   xbt_assert1((!surf_parse()),"Parse error in %s",file);
836   surf_parse_close();
837 \endverbatim
838     
839 So, to bypass the FleXML parser, you need to write your own version of the
840 surf_parse function, which should do the following:
841    - Call the corresponding STag_<tag>_fun function to simulate tag start
842    - Fill the A_<tag>_<attribute> variables with the wanted values
843    - Call the corresponding ETag_<tag>_fun function to simulate tag end
844    - (do the same for the next set of values, and loop)
845
846 Then, tell SimGrid that you want to use your own "parser" instead of the stock one:
847 \verbatim
848   surf_parse = surf_parse_bypass;
849   MSG_create_environment(NULL);
850 \endverbatim
851
852 An example of this trick is distributed in the file examples/msg/msg_test_surfxml_bypassed.c
853
854 \section faq_limits Pushing the limits
855
856 \subsection faq_context_1000 I want thousands of simulated processes
857
858 SimGrid can use either pthreads library or the UNIX98 contextes. On most
859 systems, the number of pthreads is limited and then your simulation may be
860 limited for a stupid reason. This is especially true with the current linux
861 pthreads, and I cannot get more than 2000 simulated processes with pthreads
862 on my box. The UNIX98 contexts allow me to raise the limit to 25,000
863 simulated processes on my laptop.
864
865 The <tt>--with-context</tt> option of the <tt>./configure</tt> script allows
866 you to choose between UNIX98 contextes (<tt>--with-context=ucontext</tt>)
867 and the pthread version ( (<tt>--with-context=pthread</tt>). The default
868 value is ucontext when the script detect a working UNIX98 context
869 implementation. On Windows boxes, the provided value is discarded and an
870 adapted version is picked up.
871
872 We experienced some issues with contextes on some rare systems (solaris 8
873 and lower or old alpha linuxes comes to mind). The main problem is that the
874 configure script detect the contextes as being functional when it's not
875 true. If you happen to use such a system, switch manually to the pthread
876 version, and provide us with a good patch for the configure script so that
877 it is done automatically ;)
878
879 \subsection faq_context_10000 I want hundred thousands of simulated processes
880
881 As explained above, SimGrid can use UNIX98 contextes to represent and handle
882 the simulated processes. Thanks to this, the main limitation to the number
883 of simulated processes becomes the available memory. 
884
885 Here are some tricks I had to use in order to run a token ring between
886 25,000 processes on my laptop (1Gb memory, 1.5Gb swap).
887
888  - First of all, make sure your code runs for a few hundreds processes
889    before trying to push the limit. Make sure it's valgrind-clean, ie that
890    valgrind does not report neither memory error nor memory leaks. Indeed,
891    numerous simulated processes result in *fat* simulation hindering debugging.
892
893  - It was really boring to write 25,000 entries in the deployment file, so I wrote 
894    a little script <tt>examples/gras/tokenS/make_deployment.pl</tt>, which you may
895    want to adapt to your case. You could also think about hijacking
896    the SURFXML parser (have look at \ref faq_flexml_bypassing).
897
898  - The deployment file became quite big, so I had to do what is in the FAQ
899    entry \ref faq_flexml_limit
900
901  - Each UNIX98 context has its own stack entry. As debugging this is quite 
902    hairly, the default value is a bit overestimated so that user don't get 
903    into trouble about this. You want to tune this size to increse the number 
904    of processes. This is the <tt>STACK_SIZE</tt> define in 
905    <tt>src/xbt/context_private.h</tt>, which is 128kb by default.
906    Reduce this as much as you can, but be warned that if this value is too 
907    low, you'll get a segfault. The token ring example, which is quite simple, 
908    runs with 40kb stacks.
909
910 \section faq_troubleshooting Troubleshooting
911
912 \subsection faq_compil_trouble ./configure fails!
913
914 We now only one reason for the configure to fail:
915
916  - <b>You are using a borken build environment</b>\n
917    If symptom is that configure complains about gcc not being able to build
918    executables, you are probably missing the libc6-dev package. Damn Ubuntu.
919
920 If you experience other kind of issue, please get in touch with us. We are
921 always interested in improving our portability to new systems.
922
923 \subsection faq_distcheck_fails Dude! "make check" fails on my machine!
924
925 Don't assume we never run this target, because we do. Really. Promise!
926
927 There is several reasons which may cause the make check to fail on your
928 machine:
929
930  - <b>You are using a borken libc (probably concerning the contextes)</b>.\n
931    The symptom is that the "make check" fails within the examples/msg directory.\n
932    By default, SimGrid uses something called ucontexts. This is part of the
933    libc, but it's quite undertested. For example, some (old) versions of the
934    glibc on alpha do not implement these functions, but provide the stubs
935    (which return ENOSYS: not implemented). It fools our detection mecanism
936    and leads to segfaults.\n
937    On some x86_64, the pointer to function is stored into a integer, but int
938    are 32bits only on this arch while pointers are 64bits. Our detection
939    mecanism also fails to detect the problem, which leads to segfaults.\n
940    In both cases, there is not much we can do to fix the bug. We are working
941    on a workaround for x86_64 machines, but in the meanwhile, you can
942    compile with --with-context=pthread to avoid ucontext completely. You'll
943    be a bit more limitated in the number of simulated processes you can start
944    concurently, but 5000 processes is still enough for most purposes, isn't
945    it?\n
946    This limitation is the reason why we insist on using this piece of ...
947    software even if it's so troublesome.\n
948    <b>=> use --with-pthread on AMD64 architecture that do not have an 
949    ultra-recent libc.</b>
950    
951  - <b>There is a bug in SimGrid we aren't aware of</b>.\n
952    If none of the above apply, please drop us a mail on the mailing list so
953    that we can check it out.
954
955 \subsection faq_longjmp longjmp madness in valgrind
956
957 This is when valgrind starts complaining about longjmp things, just like:
958
959 \verbatim ==21434== Conditional jump or move depends on uninitialised value(s)
960 ==21434==    at 0x420DBE5: longjmp (longjmp.c:33)
961 ==21434==
962 ==21434== Use of uninitialised value of size 4
963 ==21434==    at 0x420DC3A: __longjmp (__longjmp.S:48)
964 \endverbatim
965
966 or even when it reports scary things like:
967
968 \verbatim ==24023== Warning: client switching stacks?  SP change: 0xBE3FF618 --> 0xBE7FF710
969 x86->IR: unhandled instruction bytes: 0xF4 0xC7 0x83 0xD0
970 ==24023==          to suppress, use: --max-stackframe=4194552 or greater
971 ==24023== Your program just tried to execute an instruction that Valgrind
972 ==24023== did not recognise.  There are two possible reasons for this.
973 ==24023== 1. Your program has a bug and erroneously jumped to a non-code
974 ==24023==    location.  If you are running Memcheck and you just saw a
975 ==24023==    warning about a bad jump, it's probably your program's fault.
976 ==24023== 2. The instruction is legitimate but Valgrind doesn't handle it,
977 ==24023==    i.e. it's Valgrind's fault.  If you think this is the case or
978 ==24023==    you are not sure, please let us know.
979 ==24023== Either way, Valgrind will now raise a SIGILL signal which will
980 ==24023== probably kill your program.
981 ==24023==
982 ==24023== Process terminating with default action of signal 4 (SIGILL)
983 ==24023==  Illegal opcode at address 0x420D234
984 ==24023==    at 0x420D234: abort (abort.c:124)
985 \endverbatim
986
987 This is the sign that you didn't used the exception mecanism well. Most
988 probably, you have a <tt>return;</tt> somewhere within a <tt>TRY{}</tt>
989 block. This is <b>evil</b>, and you must not do this. Did you read the section
990 about \ref XBT_ex??
991
992 \subsection faq_valgrind Valgrind spits tons of errors!
993
994 It may happen that valgrind, the memory debugger beloved by any decent C
995 programmer, spits tons of warnings like the following :
996 \verbatim ==8414== Conditional jump or move depends on uninitialised value(s)
997 ==8414==    at 0x400882D: (within /lib/ld-2.3.6.so)
998 ==8414==    by 0x414EDE9: (within /lib/tls/i686/cmov/libc-2.3.6.so)
999 ==8414==    by 0x400B105: (within /lib/ld-2.3.6.so)
1000 ==8414==    by 0x414F937: _dl_open (in /lib/tls/i686/cmov/libc-2.3.6.so)
1001 ==8414==    by 0x4150F4C: (within /lib/tls/i686/cmov/libc-2.3.6.so)
1002 ==8414==    by 0x400B105: (within /lib/ld-2.3.6.so)
1003 ==8414==    by 0x415102D: __libc_dlopen_mode (in /lib/tls/i686/cmov/libc-2.3.6.so)
1004 ==8414==    by 0x412D6B9: backtrace (in /lib/tls/i686/cmov/libc-2.3.6.so)
1005 ==8414==    by 0x8076446: xbt_dictelm_get_ext (dict_elm.c:714)
1006 ==8414==    by 0x80764C1: xbt_dictelm_get (dict_elm.c:732)
1007 ==8414==    by 0x8079010: xbt_cfg_register (config.c:208)
1008 ==8414==    by 0x806821B: MSG_config (msg_config.c:42)
1009 \endverbatim
1010
1011 This problem is somewhere in the libc when using the backtraces and there is
1012 very few things we can do ourselves to fix it. Instead, here is how to tell
1013 valgrind to ignore the error. Add the following to your ~/.valgrind.supp (or
1014 create this file on need). Make sure to change the obj line according to
1015 your personnal mileage (change 2.3.6 to the actual version you are using,
1016 which you can retrieve with a simple "ls /lib/ld*.so").
1017
1018 \verbatim {
1019    name: Backtrace madness
1020    Memcheck:Cond
1021    obj:/lib/ld-2.3.6.so
1022    fun:dl_open_worker
1023    fun:_dl_open
1024    fun:do_dlopen
1025    fun:dlerror_run
1026    fun:__libc_dlopen_mode
1027 }\endverbatim
1028
1029 Then, you have to specify valgrind to use this suppression file by passing
1030 the <tt>--suppressions=$HOME/.valgrind.supp</tt> option on the command line.
1031 You can also add the following to your ~/.bashrc so that it gets passed
1032 automatically. Actually, it passes a bit more options to valgrind, and this
1033 happen to be my personnal settings. Check the valgrind documentation for
1034 more information.
1035
1036 \verbatim export VALGRIND_OPTS="--leak-check=yes --leak-resolution=high --num-callers=40 --tool=memcheck --suppressions=$HOME/.valgrind.supp" \endverbatim
1037
1038 \subsection faq_flexml_limit I get the message "surf_parse_lex: Assertion `next&lt;limit' failed."
1039
1040 This is because your platform file is too big for the parser. 
1041
1042 Actually, the message comes directly from FleXML, the technology on top of
1043 which the parser is built. FleXML has the bad idea of fetching the whole
1044 document in memory before parsing it. And moreover, the memory buffer size
1045 must be determinded at compilation time.
1046
1047 We use a value which seems big enough for our need without bloating the
1048 simulators footprints. But of course your mileage may vary. In this case,
1049 just edit src/surf/surfxml.l modify the definition of
1050 FLEXML_BUFFERSTACKSIZE. E.g.
1051
1052 \verbatim
1053 #define FLEXML_BUFFERSTACKSIZE 1000000000
1054 \endverbatim
1055
1056 Then recompile and everything should be fine, provided that your version of
1057 Flex is recent enough (>= 2.5.31). If not the compilation process should
1058 warn you.
1059
1060 A while ago, we worked on FleXML to reduce a bit its memory consumtion, but
1061 these issues remain. There is two things we should do:
1062
1063   - use a dynamic buffer instead of a static one so that the only limit
1064     becomes your memory, not a stupid constant fixed at compilation time
1065     (maybe not so difficult).
1066   - change the parser so that it does not need to get the whole file in
1067     memory before parsing
1068     (seems quite difficult, but I'm a complete newbe wrt flex stuff).
1069
1070 These are changes to FleXML itself, not SimGrid. But since we kinda hijacked
1071 the development of FleXML, I can grant you that any patches would be really
1072 welcome and quickly integrated.
1073
1074 \subsection faq_gras_transport GRAS spits networking error messages
1075
1076 Gras, on real platforms, naturally use regular sockets to communicate. They
1077 are deeply hiden in the gras abstraction, but when things go wrong, you may
1078 get some weird error messages. Here are some example, with the probable
1079 reason:
1080
1081  - <b>Transport endpoint is not connected</b>: several processes try to open
1082    a server socket on the same port number of the same machine. This is
1083    naturally bad and each process should pick its own port number for this.\n
1084    Maybe, you just have some processes remaining from a previous experiment 
1085    on your machine.\n
1086    Killing them may help, but again if you kill -KILL them, you'll have to
1087    wait for a while: they didn't close there sockets properly and the system
1088    needs a while to notice that this port is free again.
1089
1090  - <b>Socket closed by remote side</b>: if the remote process is not
1091    supposed to close the socket at this point, it may be dead.
1092    
1093  - <b>Connection reset by peer</b>: I found this on internet about this
1094    error. I think it's what's happening here, too:\n   
1095    <i>This basically means that a network error occurred while the client was
1096    receiving data from the server. But what is really happening is that the
1097    server actually accepts the connection, processes the request, and sends
1098    a reply to the client. However, when the server closes the socket, the
1099    client believes that the connection has been terminated abnormally
1100    because the socket implementation sends a TCP reset segment telling the
1101    client to throw away the data and report an error.\n
1102    Sometimes, this problem is caused by not properly closing the
1103    input/output streams and the socket connection. Make sure you close the
1104    input/output streams and socket connection properly. If everything is
1105    closed properly, however, and the problem persists, you can work around
1106    it by adding a one-second sleep before closing the streams and the
1107    socket. This technique, however, is not reliable and may not work on all
1108    systems.</i>\n
1109    Since GRAS sockets are closed properly (repeat after me: there is no bug
1110    in GRAS), it is either that you are closing your sockets on server side
1111    before the client get a chance to read them (use gras_os_sleep() to delay
1112    the server), or the server died awfully before the client got the data.
1113
1114 \subsection faq_deadlock There is a deadlock !!!
1115
1116 Unfortunately, we cannot debug every code written in SimGrid.  We
1117 furthermore believe that the framework provides ways enough
1118 information to debug such informations yourself. If the textual output
1119 is not enough, Make sure to check the \ref faq_visualization FAQ entry to see
1120 how to get a graphical one.
1121
1122 Now, if you come up with a really simple example that deadlocks and
1123 you're absolutely convinced that it should not, you can ask on the
1124 list. Just be aware that you'll be severely punished if the mistake is
1125 on your side... We have plenty of FAQ entries to redact and new
1126 features to implement for the impenitents! ;)
1127
1128 \subsection faq_big_fat_warning A BIG FAT WARNING is reported telling me that my platform and deployment files are too old.
1129
1130 We have decided to change the units in SimGrid. Now we use Bytes, Flops and
1131 seconds instead of MBytes, MFlops and seconds... Units should be updated
1132 accordingly and the version of platform_description should be set to a
1133 valuer greater than 1:
1134 \verbatim
1135   <platform_description version="1">
1136 \endverbatim
1137 You should try to use the surfxml_update.pl script that can be found
1138 <a href="http://gforge.inria.fr/plugins/scmcvs/cvsweb.php/contrib/platform_generation/?cvsroot=cvsroot%2Fsimgrid">here</a>.
1139
1140 \subsection faq_surf_network_latency I get weird timings when I play with the latencies.
1141
1142 OK, first of all, remember that units should be Bytes, Flops and
1143 Seconds. If you don't use such units, some SimGrid constants (e.g. the
1144 SG_TCP_CTE_GAMMA constant used in most network models) won't have the
1145 right unit and you'll end up with weird results.
1146
1147 Here is what happens with a single transfer of size L on a link
1148 (bw,lat) when nothing else happens.
1149
1150 \verbatim
1151 0-----lat--------------------------------------------------t
1152 |-----|**** real_bw =min(bw,SG_TCP_CTE_GAMMA/(2*lat)) *****|
1153 \endverbatim
1154
1155 In more complex situations, this min is the solution of a complex
1156 max-min linear system.  Have a look 
1157 <a href="http://lists.gforge.inria.fr/pipermail/simgrid-devel/2006-April/thread.html">here</a>
1158 and read the two threads "Bug in SURF?" and "Surf bug not
1159 fixed?". You'll have a few other examples of such computations. You
1160 can also read "A Network Model for Simulation of Grid Application" by
1161 Henri Casanova and Loris Marchal to have all the details. The fact
1162 that the real_bw is smaller than bw is easy to understand. The fact
1163 that real_bw is smaller than SG_TCP_CTE_GAMMA/(2*lat) is due to the
1164 window-based congestion mechanism of TCP. With TCP, you can't exploit
1165 your huge network capacity if you don't have a good round-trip-time
1166 because of the acks...
1167
1168 Anyway, what you get is t=lat + L/min(bw,SG_TCP_CTE_GAMMA/(2*lat)).
1169
1170   * if I you set (bw,lat)=(100 000 000, 0.00001), you get t =  1.00001 (you fully
1171 use your link)
1172   * if I you set (bw,lat)=(100 000 000, 0.0001),  you get t =  1.0001 (you're on the
1173 limit)
1174   * if I you set (bw,lat)=(100 000 000, 0.001),   you get t = 10.001  (ouch!)
1175
1176 This bound on the effective bandwidth of a flow is not the only thing
1177 that may make your result be unexpected. For example, two flows
1178 competing on a saturated link receive an amount of bandwidth inversely
1179 proportional to their round trip time.
1180
1181 \subsection faq_bugrepport So I've found a bug in SimGrid. How to report it?
1182
1183 We do our best to make sure to hammer away any bugs of SimGrid, but this is
1184 still an academic project so please be patient if/when you find bugs in it.
1185 If you do, the best solution is to drop an email either on the simgrid-user
1186 or the simgrid-devel mailing list and explain us about the issue.  You can
1187 also decide to open a formal bug report using the
1188 <a href="https://gforge.inria.fr/tracker/?atid=165&group_id=12&func=browse">relevant
1189 interface</a>. You need to login on the server to get the ability to submit
1190 bugs. 
1191
1192 We will do our best to solve any problem repported, but you need to help us
1193 finding the issue. Just telling "it segfault" isn't enough. Telling "It
1194 segfaults when running the attached simulator" doesn't really help either.
1195 You may find the following article interesting to see how to repport
1196 informative bug repports:
1197 http://www.chiark.greenend.org.uk/~sgtatham/bugs.html (it is not SimGrid
1198 specific at all, but it's full of good advices).
1199
1200 \author Arnaud Legrand (arnaud.legrand::imag.fr)
1201 \author Martin Quinson (martin.quinson::loria.fr)
1202
1203
1204 */
1205