Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
fix a linking error in libgras. At least I hope since another issue prevents me from...
[simgrid.git] / src / mc / private.h
1 /*      $Id: private.h 5497 2008-05-26 12:19:15Z cristianrosa $  */
2
3 /* Copyright (c) 2007 Arnaud Legrand, Bruno Donnassolo.
4    All rights reserved.                                          */
5
6 /* This program is free software; you can redistribute it and/or modify it
7  * under the terms of the license (GNU LGPL) which comes with this package. */
8
9 #ifndef MC_PRIVATE_H
10 #define MC_PRIVATE_H
11
12 #include <stdio.h>
13 #include <sys/mman.h>
14 #include "mc/mc.h"
15 #include "mc/datatypes.h"
16 #include "xbt/fifo.h"
17 #include "xbt/setset.h"
18 #include "xbt/config.h"
19 #include "xbt/function_types.h"
20 #include "xbt/mmalloc.h"
21 #include "../simix/private.h"
22
23 /****************************** Snapshots ***********************************/
24
25 typedef struct s_mc_mem_region{
26   void *start_addr;
27   void *data;
28   size_t size;
29 } s_mc_mem_region_t, *mc_mem_region_t;
30
31 typedef struct s_mc_snapshot{
32   unsigned int num_reg;
33   mc_mem_region_t *regions;
34 } s_mc_snapshot_t, *mc_snapshot_t;
35
36 void MC_take_snapshot(mc_snapshot_t);
37 void MC_restore_snapshot(mc_snapshot_t);
38 void MC_free_snapshot(mc_snapshot_t);
39
40 /********************************* MC Global **********************************/
41
42 /* Bound of the MC depth-first search algorithm */
43 #define MAX_DEPTH 1000
44
45 void MC_show_stack(xbt_fifo_t stack);
46 void MC_dump_stack(xbt_fifo_t stack);
47 void MC_replay(xbt_fifo_t stack);
48 void MC_wait_for_requests(void);
49 void MC_get_enabled_processes();
50 void MC_show_deadlock(smx_req_t req);
51
52 /********************************* Requests ***********************************/
53 int MC_request_depend(smx_req_t req1, smx_req_t req2);
54 char* MC_request_to_string(smx_req_t req);
55
56 /********************************** DPOR **************************************/
57 void MC_dpor_init(void);
58 void MC_dpor(void);
59 void MC_dpor_exit(void);
60
61 /******************************** States **************************************/
62 typedef struct mc_state {
63   xbt_setset_set_t interleave;  /* processes to interleave by the mc */
64   xbt_setset_set_t done;        /* already executed processes */
65   s_smx_req_t executed;
66 } s_mc_state_t, *mc_state_t;
67
68 extern xbt_fifo_t mc_stack;
69 extern xbt_setset_t mc_setset;
70
71 mc_state_t MC_state_new(void);
72 void MC_state_delete(mc_state_t state);
73 void MC_state_set_executed_request(mc_state_t state, smx_req_t req);
74 smx_req_t MC_state_get_executed_request(mc_state_t state);
75 smx_req_t MC_state_get_request(mc_state_t state);
76
77 /****************************** Statistics ************************************/
78 typedef struct mc_stats {
79   unsigned long state_size;
80   unsigned long visited_states;
81   unsigned long expanded_states;
82   unsigned long executed_transitions;
83 } s_mc_stats_t, *mc_stats_t;
84
85 extern mc_stats_t mc_stats;
86
87 void MC_print_statistics(mc_stats_t);
88
89 /********************************** MEMORY ******************************/
90 /* The possible memory modes for the modelchecker are standard and raw. */
91 /* Normally the system should operate in std, for switching to raw mode */
92 /* you must wrap the code between MC_SET_RAW_MODE and MC_UNSET_RAW_MODE */
93
94 extern void *std_heap;
95 extern void *raw_heap;
96 int raw_heap_fd;
97 #define STD_HEAP_SIZE   20480000        /* Maximum size of the system's heap */
98
99 /* FIXME: Horrible hack! because the mmalloc library doesn't provide yet of */
100 /* an API to query about the status of a heap, we simply call mmstats and */
101 /* because I now how does structure looks like, then I redefine it here */
102
103 struct mstats {
104   size_t bytes_total;           /* Total size of the heap. */
105   size_t chunks_used;           /* Chunks allocated by the user. */
106   size_t bytes_used;            /* Byte total of user-allocated chunks. */
107   size_t chunks_free;           /* Chunks in the free list. */
108   size_t bytes_free;            /* Byte total of chunks in the free list. */
109 };
110
111 #define MC_SET_RAW_MEM    mmalloc_set_current_heap(raw_heap)
112 #define MC_UNSET_RAW_MEM    mmalloc_set_current_heap(std_heap)
113
114 /******************************* MEMORY MAPPINGS ***************************/
115 /* These functions and data structures implements a binary interface for   */
116 /* the proc maps ascii interface                                           */
117
118 /* Each field is defined as documented in proc's manual page  */
119 typedef struct s_map_region {
120
121   void *start_addr;             /* Start address of the map */
122   void *end_addr;               /* End address of the map */
123   int prot;                     /* Memory protection */
124   int flags;                    /* Aditional memory flags */
125   void *offset;                 /* Offset in the file/whatever */
126   char dev_major;               /* Major of the device */
127   char dev_minor;               /* Minor of the device */
128   unsigned long inode;          /* Inode in the device */
129   char *pathname;               /* Path name of the mapped file */
130
131 } s_map_region;
132
133 typedef struct s_memory_map {
134
135   s_map_region *regions;        /* Pointer to an array of regions */
136   int mapsize;                  /* Number of regions in the memory */
137
138 } s_memory_map_t, *memory_map_t;
139
140 memory_map_t get_memory_map(void);
141
142
143 #endif