1 /* $Id: private.h 5497 2008-05-26 12:19:15Z cristianrosa $ */
3 /* Copyright (c) 2007 Arnaud Legrand, Bruno Donnassolo.
4 All rights reserved. */
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. */
15 #include "mc/datatypes.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"
23 /****************************** Snapshots ***********************************/
25 typedef struct s_mc_mem_region{
29 } s_mc_mem_region_t, *mc_mem_region_t;
31 typedef struct s_mc_snapshot{
33 mc_mem_region_t *regions;
34 } s_mc_snapshot_t, *mc_snapshot_t;
36 void MC_take_snapshot(mc_snapshot_t);
37 void MC_restore_snapshot(mc_snapshot_t);
38 void MC_free_snapshot(mc_snapshot_t);
40 /********************************* MC Global **********************************/
42 /* Bound of the MC depth-first search algorithm */
43 #define MAX_DEPTH 1000
45 typedef enum{MC_EXPLORE=0, MC_STOP, MC_DEADLOCK, MC_INVPROP} e_mc_exp_ctl_t;
47 e_mc_exp_ctl_t *mc_exp_ctl;
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);
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);
60 /********************************** DPOR **************************************/
61 void MC_dpor_init(void);
63 void MC_dpor_exit(void);
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 */
70 } s_mc_state_t, *mc_state_t;
72 extern xbt_fifo_t mc_stack;
73 extern xbt_setset_t mc_setset;
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);
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;
89 extern mc_stats_t mc_stats;
91 void MC_print_statistics(mc_stats_t);
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 */
98 extern void *std_heap;
99 extern void *raw_heap;
101 #define STD_HEAP_SIZE 20480000 /* Maximum size of the system's heap */
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 */
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. */
115 #define MC_SET_RAW_MEM mmalloc_set_current_heap(raw_heap)
116 #define MC_UNSET_RAW_MEM mmalloc_set_current_heap(std_heap)
118 /******************************* MEMORY MAPPINGS ***************************/
119 /* These functions and data structures implements a binary interface for */
120 /* the proc maps ascii interface */
122 /* Each field is defined as documented in proc's manual page */
123 typedef struct s_map_region {
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 */
137 typedef struct s_memory_map {
139 s_map_region *regions; /* Pointer to an array of regions */
140 int mapsize; /* Number of regions in the memory */
142 } s_memory_map_t, *memory_map_t;
144 memory_map_t get_memory_map(void);