资源简介
采用seg-list结构,易于理解,适合和我一样的弱渣使用,好好调参,可以得到93分,我觉得可以接受
代码片段和文件信息
/*
ID:1600011090 NAME:Chen HaoRan
MIAN IDEA:
I use the seglist to complete it
First i store 40 pointers in the heap free_head[20]
in which free_head[i] is the head pointer of the rank
i free_listeach list will contain the size of [2^i2^(i+1)
block.
Then the free_tail[20] pointer to the tail of 20 free_
list.
For mallocingi use the first_fit to find a place in the
suitable listby testing we now it can get most scores.Then
delete it from the free_list.
For freeingi just add it to the free_list.
For coalescingdelete the neiborhood free blocks from the
listcombine themadd it to the free_list again.
Reallock function should tell the rank of the oldsize and
and the newsize to determine whether we should copy the data from
old place to a new place.
*/
#include
#include
#include
#include
#include
#include “mm.h“
#include “memlib.h“
/* If you want debugging output use the following macro. When you hand
* in remove the #define DEBUG line. */
//#define DEBUG
#ifdef DEBUG
# define dbg_printf(...) printf(__VA_ARGS__)
#else
# define dbg_printf(...)
#endif
/* do not change the following! */
#ifdef DRIVER
/* create aliases for driver tests */
#define malloc mm_malloc
#define free mm_free
#define realloc mm_realloc
#define calloc mm_calloc
#endif /* def DRIVER */
/*
the macro below is what i will use in the program
the meaning of them are easy to tell by their names
*/
#define WSIZE 4
#define DSIZE 8
#define BLOCKSIZE 16
#define INFOSIZE 8
#define CHUNKSIZE 0x150
#define MAX(x y) ((x) > (y)? (x) : (y))
#define ALIGNMENT 8
#define ALIGN(size) (((size_t)(size) + (ALIGNMENT - 1)) & ~0x7)
#define PACK(size alloc) ((size) | (alloc))
#define GET(p) (*(unsigned int *)(p))
#define PUT(p val) (*(unsigned int *)(p) = (val))
#define GET_SIZE(p) (GET(p) & ~0x7)
#define GET_ALLOC(p) (GET(p) & 0x1)
#define HEAD(bp) ((char *)(bp) - WSIZE)
#define FOOT(bp) ((char *)(bp) + GET_SIZE(HEAD(bp)) - DSIZE)
#define NEXT_BLKP(bp) ((char *)(bp) + GET_SIZE(((char *)(bp) - WSIZE)))
#define PREV_BLKP(bp) ((char *)(bp) - GET_SIZE(((char *)(bp) - DSIZE)))
#define SIZE(bp) (GET_SIZE(HEAD(bp)))
#define PREV_SIZE(bp) (GET_SIZE((char *)(bp) - DSIZE))
#define NEXT_SIZE(bp) (GET_SIZE((char *)(bp) + SIZE(bp) - WSIZE))
#define ALLOC(bp) (GET_ALLOC(HEAD(bp)))
#define FATHER(bp) ((char *)(bp) - GET(bp))
#define CHILD(bp) ((char *)(bp) + GET((char *)(bp) + WSIZE))
#define PUT_FATHER(bp pre) PUT(bp (unsigned int)((char *)(bp) - (char *)(pre)))
#define PUT_CHILD(bp suc) PUT((char *)(bp) + WSIZE (unsigned int)((char *)(suc) - (char *)(bp)))
#define ALLNULL 0
#define HEADNULL 1
#define TAILNULL 2
#define NORMAL 3
/*
here are the global variablepoint to the heapfree_list‘s
headfree_list‘s tail
相关资源
- labview魔方程序
- 一个labview仿真的函数信号发生器.vi
- labview编程软件滤波器以及编写程序设
- labview语音输入输出
- labview中的DAQ助手采集多个通道电压
- Labview与CH372CH375的通信测试
- LabVIEW钢琴实例
- 编程实现二维DCT变换
- silicon lab公司的收音IC SI47XX全套开发工
- 图像二值化
- 用FFT对信号进行频谱分析
- nachos-lab 02
- Tone-Reservation
- QGA 量子遗传算法
- 差分形式的阻滞增长模型
- 遗传算法的M文件
- LabVIEW入门与实战开发100例190153
- LABVIEW做的蓝牙数据发送程序.vi
- VCS lab 和 VCS lab guide
- 基于labview的变声器
- 基于labview的方差标准差计算(求方差
- smart和labview通讯(smart_connet.vi)
- LabVIEW 数据采集 模拟量+编码器(Daq
- LabVIEW 声音信号的采集与存储.vi
- LabVIEW步进电机控制.vi
- 多通道数据采集.vi(labview)
- labview智能电梯(6层电梯.vi)
- 用labview编写的一个神经网络Vi图
- 基于Labview的电子秤的设计.docx
- labview汽车仪表盘
评论
共有 条评论