Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Set level COORD_HOST_LEVEL and COORD_ASR_LEVEL if there are used.
[simgrid.git] / src / mc / mc_memory.c
1 #include <sys/stat.h>
2 #include <fcntl.h>
3 #include "mc/mc.h"
4 #include "private.h"
5 #include "xbt/log.h"
6 #define _GNU_SOURCE
7
8
9
10 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_memory, mc,
11                                 "Logging specific to MC (memory)");
12
13 /* Pointers to each of the heap regions to use */
14 void *std_heap = NULL;          /* memory erased each time the MC stuff rollbacks to the beginning. Almost everything goes here */
15 void *raw_heap = NULL;          /* memory persistent over the MC rollbacks. Only MC stuff should go there */
16
17 /* Initialize the model-checker memory subsystem */
18 /* It creates the two heap regions: std_heap and raw_heap */
19 void MC_memory_init()
20 {
21 /* Create the first region HEAP_OFFSET bytes after the heap break address */
22   std_heap = mmalloc_get_default_md();
23   xbt_assert(std_heap != NULL);
24
25 /* Create the second region a page after the first one ends + safety gap */
26 /*  raw_heap_fd = shm_open("raw_heap", O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);*/
27   raw_heap = mmalloc_attach(-1, (char*)(std_heap) + STD_HEAP_SIZE + getpagesize());
28   xbt_assert(raw_heap != NULL);
29 }
30
31 /* Finish the memory subsystem */
32 #include "xbt_modinter.h"
33 void MC_memory_exit(void)
34 {
35   if (raw_heap)
36     mmalloc_detach(raw_heap);
37 }