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 */
24 I_ SM_major_gen_size = 0;
25 FILE *SM_statsfile = NULL;
27 I_ SM_stats_summary = 0;
28 I_ SM_stats_verbose = 0;
31 /*To SizeHooks: I_ SM_word_heap_size = DEFAULT_HEAP_SIZE; */
32 /*To SizeHooks: StgFloat SM_pc_free_heap = DEFAULT_PC_FREE; */
33 extern I_ SM_word_stk_size; /*To SizeHooks: = DEFAULT_STACKS_SIZE; */
35 I_ MaxResidency = 0; /* in words; for stats only */
36 I_ ResidencySamples = 0; /* for stats only */
40 /* no proto because some machines use const and some do not */
53 if (c == 'g' || c == 'G')
54 m *= 1000*1000*1000; /* UNchecked! */
55 else if (c == 'm' || c == 'M')
56 m *= 1000*1000; /* We do not use powers of 2 (1024) */
57 else if (c == 'k' || c == 'K') /* to avoid possible bad effects on */
58 m *= 1000; /* a direct-mapped cache. */
59 else if (c == 'w' || c == 'W')
69 fprintf(stderr, "initSM: Bad RTS option: %s\n", s);
73 extern long strtol PROTO((const char *, char **, int)); /* ToDo: properly? */
76 initSM(rts_argc, rts_argv, statsfile)
83 /* save statsfile info */
84 SM_statsfile = statsfile;
86 /* slurp through RTS args */
88 for (arg = 0; arg < rts_argc; arg++) {
89 if (rts_argv[arg][0] == '-') {
90 switch(rts_argv[arg][1]) {
92 SM_word_heap_size = decode(rts_argv[arg]+2) / sizeof(W_);
94 if (SM_word_heap_size <= 0) badoption( rts_argv[arg] );
98 SM_pc_free_heap = atof(rts_argv[arg]+2);
100 if ((SM_pc_free_heap < 0) || (SM_pc_free_heap > 100))
101 badoption( rts_argv[arg] );
105 SM_alloc_size = decode(rts_argv[arg]+2) / sizeof(W_);
107 if (SM_alloc_size == 0) SM_alloc_size = DEFAULT_ALLOC_SIZE;
111 SM_major_gen_size = decode(rts_argv[arg]+2) / sizeof(W_);
115 if (strcmp(rts_argv[arg]+2, "2s") == 0) {
116 SM_force_gc = USE_2s;
117 } else if (strcmp(rts_argv[arg]+2, "1s") == 0) {
118 badoption( rts_argv[arg] ); /* ToDo ! */
120 badoption( rts_argv[arg] );
125 SM_word_stk_size = decode(rts_argv[arg]+2) / sizeof(W_);
127 if (SM_word_stk_size == 0) badoption( rts_argv[arg] );
132 /* statsfile has already been determined */
136 /* statsfile has already been determined */
143 if (rts_argv[arg][2] != '\0')
144 SM_trace = (I_) strtol(rts_argv[arg]+2, (char **)NULL, 0);
151 dualmodeInfo.resid_to_compact = atof(rts_argv[arg]+2);
152 dualmodeInfo.resid_from_compact = dualmodeInfo.resid_from_compact + 0.05;
153 if (dualmodeInfo.resid_from_compact < 0.0 ||
154 dualmodeInfo.resid_to_compact > 1.0) {
155 badoption( rts_argv[arg] );
160 /* otherwise none of my business */
164 /* else none of my business */
167 SM_alloc_min = (I_) (SM_word_heap_size * SM_pc_free_heap / 100);
169 return(0); /* all's well */
174 \section[storage-manager-exit]{Winding up the storage manager}
182 stat_exit(sm_info->hp - hp_start);
184 return(0); /* I'm happy */