1 \section[storage-manager-init]{Initialising the storage manager}
3 To initialise the storage manager, we pass it:
6 An @argc@/@argv@ combo, which are the command-line arguments that have
7 been deemed to belong to the runtime system. The initialisation
8 routine can slurp around in there for information of interest to
12 A filehandle to which any storage-manager statistics should be written.
17 #include "SMinternal.h"
19 /* global vars to hold some storage-mgr details; */
20 /* decls for these are in SMinternal.h */
22 I_ SM_word_heap_size = DEFAULT_HEAP_SIZE;
24 StgFloat SM_pc_free_heap = DEFAULT_PC_FREE;
26 I_ SM_major_gen_size = 0;
27 I_ SM_word_stk_size = DEFAULT_STACKS_SIZE;
28 FILE *SM_statsfile = NULL;
30 I_ SM_stats_summary = 0;
31 I_ SM_stats_verbose = 0;
34 I_ MaxResidency = 0; /* in words; for stats only */
35 I_ ResidencySamples = 0; /* for stats only */
39 /* no proto because some machines use const and some do not */
52 if (c == 'g' || c == 'G')
53 m *= 1000*1000*1000; /* UNchecked! */
54 else if (c == 'm' || c == 'M')
55 m *= 1000*1000; /* We do not use powers of 2 (1024) */
56 else if (c == 'k' || c == 'K') /* to avoid possible bad effects on */
57 m *= 1000; /* a direct-mapped cache. */
58 else if (c == 'w' || c == 'W')
68 fprintf(stderr, "initSM: Bad RTS option: %s\n", s);
72 extern long strtol PROTO((const char *, char **, int)); /* ToDo: properly? */
75 initSM(rts_argc, rts_argv, statsfile)
82 /* save statsfile info */
83 SM_statsfile = statsfile;
85 /* slurp through RTS args */
87 for (arg = 0; arg < rts_argc; arg++) {
88 if (rts_argv[arg][0] == '-') {
89 switch(rts_argv[arg][1]) {
91 SM_word_heap_size = decode(rts_argv[arg]+2) / sizeof(W_);
93 if (SM_word_heap_size <= 0) badoption( rts_argv[arg] );
97 SM_pc_free_heap = atof(rts_argv[arg]+2);
99 if ((SM_pc_free_heap < 0) || (SM_pc_free_heap > 100))
100 badoption( rts_argv[arg] );
104 SM_alloc_size = decode(rts_argv[arg]+2) / sizeof(W_);
106 if (SM_alloc_size == 0) SM_alloc_size = DEFAULT_ALLOC_SIZE;
110 SM_major_gen_size = decode(rts_argv[arg]+2) / sizeof(W_);
114 if (strcmp(rts_argv[arg]+2, "2s") == 0) {
115 SM_force_gc = USE_2s;
116 } else if (strcmp(rts_argv[arg]+2, "1s") == 0) {
117 badoption( rts_argv[arg] ); /* ToDo ! */
119 badoption( rts_argv[arg] );
124 SM_word_stk_size = decode(rts_argv[arg]+2) / sizeof(W_);
126 if (SM_word_stk_size == 0) badoption( rts_argv[arg] );
131 /* statsfile has already been determined */
135 /* statsfile has already been determined */
142 if (rts_argv[arg][2] != '\0')
143 SM_trace = (I_) strtol(rts_argv[arg]+2, (char **)NULL, 0);
150 dualmodeInfo.resid_to_compact = atof(rts_argv[arg]+2);
151 dualmodeInfo.resid_from_compact = dualmodeInfo.resid_from_compact + 0.05;
152 if (dualmodeInfo.resid_from_compact < 0.0 ||
153 dualmodeInfo.resid_to_compact > 1.0) {
154 badoption( rts_argv[arg] );
159 /* otherwise none of my business */
163 /* else none of my business */
166 SM_alloc_min = (I_) (SM_word_heap_size * SM_pc_free_heap / 100);
168 return(0); /* all's well */
173 \section[storage-manager-exit]{Winding up the storage manager}
181 stat_exit(sm_info->hp - hp_start);
183 return(0); /* I'm happy */