资源简介
lab_garbage_collector.zip
代码片段和文件信息
/* $Id$ */
/*
* Khalil Amiri
* amiri+@cs.cmu.edu
*
* CS213 - Fall 99 - Lab assignment 3
*
*/
#include
#include
#include
#include
#include
#include “ftime.h“
#include “memlib.h“
#include “malloc.h“
#include “dump.h“
#include “useful.h“
#include “getopt.h“
#include “tracefiles.h“
void usage(void);
/* magic numbers */
/* Win32: REF_TIME Adaptive Modification */
#define SPACE_UTIL_METRIC_WEIGHT 0.33
//#define REF_TIME 110.0
#define REF_TIME 0.035
#define MIN(ab) ( (a) < (b) ? (a):(b) )
/* test data structures */
typedef struct range_t {
struct range_t *next;
char *lo *hi;
} range_t;
typedef struct {
enum {ALLOC FREE} type;
long index;
long size;
} memop_t;
typedef struct {
int weight;
unsigned num_blocks;
long num_ops;
long suggested_heap_size;
memop_t *ops;
char *blocks[20000];
size_t *block_sizes;
} trace_t;
stats_t *stats;
/* Command-line options */
static int verbose = 1;
static double ftime_tolerance = 0.05;
static int dump = 0;
/*****************
* Range routines
*****************/
static range_t *ranges = NULL;
static range_t *garbage = NULL;
static trace_t *t = NULL;
/* Check if a pointer is 4-byte aligned */
#define IS_ALIGNED(p) ((((unsigned long)(p))%4) == 0)
int add_range (char *lo long size)
{
char *hi = lo + size - 1;
range_t *p;
assert(size > 0);
/* Check alignment */
if (!IS_ALIGNED(lo)) {
fprintf(stderr “Misaligned region returned\n“);
if (verbose)
fprintf(stderr “Address: %p\n“ lo);
return 0;
}
/* Region lies within heap */
if (lo < dseg_lo || lo > dseg_hi || hi < dseg_lo || hi > dseg_hi) {
fprintf(stderr “Region lies outside heap area\n“);
if (verbose) {
fprintf(stderr “Region: %p - %p\n“ lo hi);
fprintf(stderr “Heap: %p - %p\n“ dseg_lo dseg_hi);
}
return 0;
}
/* Region does not overlap any other region */
for (p = ranges; p != NULL; p = p->next) {
if ((lo >= p->lo && lo <= p-> hi) ||
(hi >= p->lo && hi <= p->hi)) {
fprintf(stderr “Region overlap detected\n“);
if (verbose) {
fprintf(stderr “Region 1: %p - %p\n“ lo hi);
fprintf(stderr “Region 2: %p - %p\n“ p->lo p->hi);
}
return 0;
}
}
/* Clobber region (zero miswritten control records) */
//bzero(lo size);
memset(lo 0 size);
p = (range_t *)malloc(sizeof(range_t));
p-> next = ranges;
p->lo = lo;
p->hi = hi;
ranges = p;
return 1;
}
void remove_range (char *lo)
{
range_t *p **prevpp = &ranges;
for (p = ranges; p != NULL; p = p->next) {
if (p->lo == lo) {
*prevpp = p->next;
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2011-10-25 17:57 lab_garbage_collector\
文件 90890 2011-10-23 22:19 lab_garbage_collector\amptjp.dump
目录 0 2011-10-25 17:56 lab_garbage_collector\artificial\
文件 76355 2009-04-14 19:59 lab_garbage_collector\artificial\binary.rep
文件 156357 2009-04-14 19:59 lab_garbage_collector\artificial\binary2.rep
文件 134602 2009-04-14 19:59 lab_garbage_collector\artificial\coalescing.rep
文件 929 2009-04-14 19:59 lab_garbage_collector\artificial\gen_binary.pl.txt
文件 805 2009-04-14 19:59 lab_garbage_collector\artificial\gen_coalescing.pl
文件 1657 2009-04-14 19:59 lab_garbage_collector\artificial\gen_random.pl
文件 25341 2009-04-14 19:59 lab_garbage_collector\artificial\random.rep
文件 26323 2009-04-14 19:59 lab_garbage_collector\artificial\random2.rep
文件 116867 2011-10-23 22:19 lab_garbage_collector\binary.dump
文件 221348 2011-10-23 22:19 lab_garbage_collector\binary2.dump
文件 94963 2011-10-23 22:19 lab_garbage_collector\cccp.dump
文件 109117 2011-10-23 22:19 lab_garbage_collector\cp-decl.dump
目录 0 2011-10-25 17:56 lab_garbage_collector\Debug\
文件 41504 2011-10-25 17:54 lab_garbage_collector\Debug\driver.obj
文件 0 2011-10-25 17:54 lab_garbage_collector\Debug\driver.sbr
文件 6659 2011-10-22 16:02 lab_garbage_collector\Debug\dump.obj
文件 0 2011-10-22 16:02 lab_garbage_collector\Debug\dump.sbr
文件 10689 2011-10-22 16:02 lab_garbage_collector\Debug\ftime_win32.obj
文件 0 2011-10-22 16:02 lab_garbage_collector\Debug\ftime_win32.sbr
文件 2491392 2011-10-25 17:54 lab_garbage_collector\Debug\gc.bsc
文件 241764 2011-10-25 17:54 lab_garbage_collector\Debug\gc.exe
文件 372576 2011-10-25 17:54 lab_garbage_collector\Debug\gc.ilk
文件 247576 2011-10-25 17:54 lab_garbage_collector\Debug\gc.pch
文件 615424 2011-10-25 17:54 lab_garbage_collector\Debug\gc.pdb
文件 13845 2011-10-22 16:02 lab_garbage_collector\Debug\getopt.obj
文件 0 2011-10-22 16:02 lab_garbage_collector\Debug\getopt.sbr
文件 10562 2011-10-25 17:54 lab_garbage_collector\Debug\malloc.obj
文件 0 2011-10-25 17:54 lab_garbage_collector\Debug\malloc.sbr
............此处省略38个文件信息
- 上一篇:灰色关联分析软件GM
- 下一篇:Windows无线网卡驱动的开发
评论
共有 条评论