Need for a function to reset a platform
Inria Forge bug #2179: https://gforge.inria.fr/tracker/index.php?func=detail&aid=2179&group_id=12&atid=165
From: Arnaud Legrand
Date: 06/03/2007 12:50
I'm just pasting Fred's email on why the issue has been raised:
>> I'm currently writing a SimDag simulator. As in the examples/ code, I
>> get rid off my complex platform structure to rely on SD_workstation_*
>> functions. As a consequence I have to parse the XML description of my
>> platform (if I want to bypass it, I have to manage that complex
>> structure again).
>>
>> This parsing step can be quite costly when platforms comprise a lot of
>> workstations. My idea was then to create my environment once and then
>> perform my simulations on several DAGs onto this platform. But I got the
>> following error during the second simulation :
>>
>> [25.020002] simdag/sd_global.c:126: [sd_kernel/INFO] Starting simulation...
>> [25.020002] simdag/sd_global.c:141: [sd_kernel/INFO] Executing task 'node#0'
>> [25.020003] simdag/sd_global.c:170: [sd_kernel/INFO] Task 'node#0' done
>> ===10031== Invalid write of size 4
>> ==10031== at 0x403EC2D: xbt_swag_insert (swag.c:88)
>> ==10031== by 0x4091802: __SD_task_set_state (sd_task.c:142)
>> ==10031== by 0x4095DB2: __SD_task_just_done (sd_task.c:710)
>> ==10031== by 0x408F4FE: SD_simulate (sd_global.c:172)
>> ==10031== by 0x804C556: main (main.c:109)
>> ==10031== Address 0x441A674 is 4 bytes inside a block of size 104 free'd
>> ==10031== at 0x401CFCF: free (vg_replace_malloc.c:235)
>> ==10031== by 0x4093978: SD_task_destroy (sd_task.c:901)
>> ==10031== by 0x804C40D: freeSimgridTasks (main.c:53)
>> ==10031== by 0x804C679: main (main.c:128)
>>
>> This is because (in my own opinion), internal SD data_structures are not
>> reset between SD_simulate calls. As I can't use SD_exit () and SD_init
>> () without having to create my platform environment again, I added the
>> two following functions to the SimDag API
>>
>> void SD_application_init (void)
>> void SD_application_clean (void)
>>
>> in which I allocate/clean the xbt_swags relative to tasks. It's quite
>> unclean and not to be commited (I think). For instance, some swags can
>> be double freed if ones does not pay attention. But it works just fine
>> with some minimal care.
>>
>> This mail was just intended to explain what my problem was and how I
>> solved it. Maybe other users of SimDag have the same need for only
>> resetting the application part of their simulators.
Resetting the application just needs to be done in simdag. However resetting the platform is also important in this case (to reset the virtual clock and the traces if any) and should be done in SURF.