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 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);
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);
56 /********************************** DPOR **************************************/
57 void MC_dpor_init(void);
59 void MC_dpor_exit(void);
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 */
66 } s_mc_state_t, *mc_state_t;
68 extern xbt_fifo_t mc_stack;
69 extern xbt_setset_t mc_setset;
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);
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;
85 extern mc_stats_t mc_stats;
87 void MC_print_statistics(mc_stats_t);
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 */
94 extern void *std_heap;
95 extern void *raw_heap;
97 #define STD_HEAP_SIZE 20480000 /* Maximum size of the system's heap */
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 */
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. */
111 #define MC_SET_RAW_MEM mmalloc_set_current_heap(raw_heap)
112 #define MC_UNSET_RAW_MEM mmalloc_set_current_heap(std_heap)
114 /******************************* MEMORY MAPPINGS ***************************/
115 /* These functions and data structures implements a binary interface for */
116 /* the proc maps ascii interface */
118 /* Each field is defined as documented in proc's manual page */
119 typedef struct s_map_region {
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 */
133 typedef struct s_memory_map {
135 s_map_region *regions; /* Pointer to an array of regions */
136 int mapsize; /* Number of regions in the memory */
138 } s_memory_map_t, *memory_map_t;
140 memory_map_t get_memory_map(void);