summaryrefslogtreecommitdiff
path: root/allchblk.c
diff options
context:
space:
mode:
authorivmai <ivmai>2009-09-10 22:08:05 +0200
committerIvan Maidanski <ivmai@mail.ru>2011-07-26 19:06:46 +0200
commit14c324f8bdad7720cd39abe0cc86b0295b2f1260 (patch)
treed7b5cdecd774e34e057fda27b975e5c5d88a76c7 /allchblk.c
parentf69ca1a96be89fa7e35ba7f8e958dc6a58a6a893 (diff)
2009-09-10 Ivan Maidanski <ivmai@mail.ru>
(diff118_cvs - superseding diff53) * allchblk.c (MUNMAP_THRESHOLD): Move macro definition out of a function. * allchblk.c (GC_unmap_threshold): New global variable definition (initialized to MUNMAP_THRESHOLD). * allchblk.c (GC_unmap_old): Use GC_unmap_threshold instead of MUNMAP_THRESHOLD; skip unmapping if GC_unmap_threshold is 0. * doc/README.environment (GC_UNMAP_THRESHOLD): Add information. * misc.c (GC_unmap_threshold): New variable declaration. * misc.c (GC_init_inner): Recognize "GC_UNMAP_THRESHOLD" environment variable to set GC_unmap_threshold value (only if USE_MUNMAP).
Diffstat (limited to 'allchblk.c')
-rw-r--r--allchblk.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/allchblk.c b/allchblk.c
index 627ef90..85cba94 100644
--- a/allchblk.c
+++ b/allchblk.c
@@ -381,29 +381,31 @@ STATIC void GC_add_to_fl(struct hblk *h, hdr *hhdr)
#ifdef USE_MUNMAP
+# ifndef MUNMAP_THRESHOLD
+# define MUNMAP_THRESHOLD 6
+# endif
+
+int GC_unmap_threshold = MUNMAP_THRESHOLD;
+
/* Unmap blocks that haven't been recently touched. This is the only way */
/* way blocks are ever unmapped. */
void GC_unmap_old(void)
{
struct hblk * h;
hdr * hhdr;
- word sz;
- unsigned short last_rec, threshold;
int i;
-# ifndef MUNMAP_THRESHOLD
-# define MUNMAP_THRESHOLD 6
-# endif
+
+ if (GC_unmap_threshold == 0)
+ return; /* unmapping disabled */
for (i = 0; i <= N_HBLK_FLS; ++i) {
for (h = GC_hblkfreelist[i]; 0 != h; h = hhdr -> hb_next) {
hhdr = HDR(h);
if (!IS_MAPPED(hhdr)) continue;
- threshold = (unsigned short)(GC_gc_no - MUNMAP_THRESHOLD);
- last_rec = hhdr -> hb_last_reclaimed;
- if ((last_rec > GC_gc_no || last_rec < threshold)
- && threshold < GC_gc_no /* not recently wrapped */) {
- sz = hhdr -> hb_sz;
- GC_unmap((ptr_t)h, sz);
+
+ if ((unsigned short)GC_gc_no - hhdr -> hb_last_reclaimed >
+ (unsigned short)GC_unmap_threshold) {
+ GC_unmap((ptr_t)h, hhdr -> hb_sz);
hhdr -> hb_flags |= WAS_UNMAPPED;
}
}