Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Compile fix: smx_process_t->request is a s_smx_req_t now.
[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 typedef enum{MC_EXPLORE=0, MC_STOP, MC_DEADLOCK, MC_INVPROP} e_mc_exp_ctl_t;
46
47 e_mc_exp_ctl_t *mc_exp_ctl;
48
49 void MC_show_stack(xbt_fifo_t stack);
50 void MC_dump_stack(xbt_fifo_t stack);
51 void MC_replay(xbt_fifo_t stack);
52 void MC_wait_for_requests(void);
53 void MC_get_enabled_processes();
54 void MC_show_deadlock(smx_req_t req);
55
56 /********************************* Requests ***********************************/
57 int MC_request_depend(smx_req_t req1, smx_req_t req2);
58 char* MC_request_to_string(smx_req_t req);
59
60 /********************************** DPOR **************************************/
61 void MC_dpor_init(void);
62 void MC_dpor(void);
63 void MC_dpor_exit(void);
64
65 /******************************** States **************************************/
66 typedef struct mc_state {
67   xbt_setset_set_t interleave;  /* processes to interleave by the mc */
68   xbt_setset_set_t done;        /* already executed processes */
69   s_smx_req_t executed;
70 } s_mc_state_t, *mc_state_t;
71
72 extern xbt_fifo_t mc_stack;
73 extern xbt_setset_t mc_setset;
74
75 mc_state_t MC_state_new(void);
76 void MC_state_delete(mc_state_t state);
77 void MC_state_set_executed_request(mc_state_t state, smx_req_t req);
78 smx_req_t MC_state_get_executed_request(mc_state_t state);
79 smx_req_t MC_state_get_request(mc_state_t state);
80
81 /****************************** Statistics ************************************/
82 typedef struct mc_stats {
83   unsigned long state_size;
84   unsigned long visited_states;
85   unsigned long expanded_states;
86   unsigned long executed_transitions;
87 } s_mc_stats_t, *mc_stats_t;
88
89 extern mc_stats_t mc_stats;
90
91 void MC_print_statistics(mc_stats_t);
92
93 /********************************** MEMORY ******************************/
94 /* The possible memory modes for the modelchecker are standard and raw. */
95 /* Normally the system should operate in std, for switching to raw mode */
96 /* you must wrap the code between MC_SET_RAW_MODE and MC_UNSET_RAW_MODE */
97
98 extern void *std_heap;
99 extern void *raw_heap;
100 int raw_heap_fd;
101 #define STD_HEAP_SIZE   20480000        /* Maximum size of the system's heap */
102
103 /* FIXME: Horrible hack! because the mmalloc library doesn't provide yet of */
104 /* an API to query about the status of a heap, we simply call mmstats and */
105 /* because I now how does structure looks like, then I redefine it here */
106
107 struct mstats {
108   size_t bytes_total;           /* Total size of the heap. */
109   size_t chunks_used;           /* Chunks allocated by the user. */
110   size_t bytes_used;            /* Byte total of user-allocated chunks. */
111   size_t chunks_free;           /* Chunks in the free list. */
112   size_t bytes_free;            /* Byte total of chunks in the free list. */
113 };
114
115 #define MC_SET_RAW_MEM    mmalloc_set_current_heap(raw_heap)
116 #define MC_UNSET_RAW_MEM    mmalloc_set_current_heap(std_heap)
117
118 /******************************* MEMORY MAPPINGS ***************************/
119 /* These functions and data structures implements a binary interface for   */
120 /* the proc maps ascii interface                                           */
121
122 /* Each field is defined as documented in proc's manual page  */
123 typedef struct s_map_region {
124
125   void *start_addr;             /* Start address of the map */
126   void *end_addr;               /* End address of the map */
127   int prot;                     /* Memory protection */
128   int flags;                    /* Aditional memory flags */
129   void *offset;                 /* Offset in the file/whatever */
130   char dev_major;               /* Major of the device */
131   char dev_minor;               /* Minor of the device */
132   unsigned long inode;          /* Inode in the device */
133   char *pathname;               /* Path name of the mapped file */
134
135 } s_map_region;
136
137 typedef struct s_memory_map {
138
139   s_map_region *regions;        /* Pointer to an array of regions */
140   int mapsize;                  /* Number of regions in the memory */
141
142 } s_memory_map_t, *memory_map_t;
143
144 memory_map_t get_memory_map(void);
145
146
147 #endif