资源简介
哈工大计算机系统Lab8 报告+源代码,供学弟学妹参考。

代码片段和文件信息
/*
* mm-naive.c - The fastest least memory-efficient malloc package.
*
* In this naive approach a block is allocated by simply incrementing
* the brk pointer. A block is pure payload. There are no headers or
* footers. Blocks are never coalesced or reused. Realloc is
* implemented directly using mm_malloc and mm_free.
*
* NOTE TO STUDENTS: Replace this header comment with your own header
* comment that gives a high level description of your solution.
*/
#include
#include
#include
#include
#include
#include “mm.h“
#include “memlib.h“
/*********************************************************
* NOTE TO STUDENTS: Before you do anything else please
* provide your team information in the following struct.
********************************************************/
team_t team = {
/* Team name */
“hzj1173710108“
/* First member‘s full name */
“hzj“
/* First member‘s email address */
“@ZJ“
/* Second member‘s full name (leave blank if none) */
““
/* Second member‘s email address (leave blank if none) */
““
};
/* single word (4) or double word (8) alignment */
#define ALIGNMENT 8
/* rounds up to the nearest multiple of ALIGNMENT */
#define ALIGN(size) (((size) + (ALIGNMENT-1)) & ~0x7)
#define SIZE_T_SIZE (ALIGN(sizeof(size_t)))
#define WSIZE 4
#define DSIZE 8 /*Double word size*/
#define CHUNKSIZE (1<<12) /*the page size in bytes is 4K*/
#define MAX(xy) ((x)>(y)?(x):(y))
#define PACK(sizealloc) ((size) | (alloc))
#define GET(p) (*(unsigned int *)(p))
#define PUT(pval) (*(unsigned int *)(p) = (val))
#define GET_SIZE(p) (GET(p) & ~0x7)
#define GET_ALLOC(p) (GET(p) & 0x1)
#define HDRP(bp) ((char *)(bp)-WSIZE)
#define FTRP(bp) ((char *)(bp)+GET_SIZE(HDRP(bp))-DSIZE)
#define NEXT_BLKP(bp) ((char *)(bp)+GET_SIZE(((char *)(bp)-WSIZE)))
#define PREV_BLKP(bp) ((char *)(bp)-GET_SIZE(((char *)(bp)-DSIZE)))
static void *extend_heap(size_t words);
static void *coalesce(void *bp);
static void *find_fit(size_t size);
static void place(void *bpsize_t asize);
static char *heap_listp = 0;
/*
* mm_init - initialize the malloc package.
* The return value should be -1 if there was a problem in performing the initialization 0 otherwise
*/
int mm_init(void)
{
if((heap_listp = mem_sbrk(4*WSIZE))==(void *)-1){
return -1;
}
PUT(heap_listp0);
PUT(heap_listp+(1*WSIZE)PACK(DSIZE1));
PUT(heap_listp+(2*WSIZE)PACK(DSIZE1));
PUT(heap_listp+(3*WSIZE)PACK(01));
heap_listp += (2*WSIZE);
if(extend_heap(CHUNKSIZE/WSIZE)==NULL){
return -1;
}
return 0;
}
static void *extend_heap(size_t words){
char *bp;
size_t size;
size = (words%2) ? (words+1)*WSIZE : words*WSIZE;
if((long)(bp=mem_sbrk(size))==(void *)-1)
return NULL;
PUT(HDRP(bp)PACK(size0));
PUT(FTRP(bp)PACK(size0));
PUT(HDRP(NEXT_BLKP(bp))PACK(01));
return coalesce(
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 1228026 2018-12-29 20:30 1173710108 侯泽健.doc
文件 6161 2018-12-29 19:32 mm.c
----------- --------- ---------- ----- ----
1234187 2
- 上一篇:Pla
yerPrefs可视化工具 - 下一篇:日语面试集锦
相关资源
- stm32做的红外遥控解码程序
- 信号奇异点Lipschitz指数计算
- 哈工大的高等电磁学电磁场课件
- Linux操作系统课件PPT
- IBM Rational Software Architect 9.0破解文件
- Born-Infeld-dilaton-Lifshitz全息超导体的光
- 具有非线性电动力学的Lifshitz黑洞中铁
- Sun 为东京工业大学提供100 TeraFLOPS 超
- The Existence of Optimal Control for Fully Cou
- 超详细课件哈工大第七版理论力学
- PC机与嵌入式计算机系统串行通讯的硬
- 计算机系统结构教程清华版
- 哈工大威海-嵌入式实验报告答案
- 卫星通信知识点总结不包含计算题
- 哈工大单片机教材课后答案张毅刚编
- 深入理解计算机系统_第三版配套完整
- Game Engine Architecture游戏引擎架构.pdf
- 哈工大深圳NLP考试参考
- 哈工大威海编译原理实验报告和源代
- 哈工大威海-编译原理实验报告和源码
- 哈工大自然语言处理课件及实验
- 《计算机系统安全原理与技术》第3版
- 哈工大五个校区校园导航
- UPnP-av-AVArchitecture-v1-中文
- 哈工大计算机考研内部辅导班笔记
- 计算机系统结构课后习题答案-完整版
- 深入理解计算机系统 课后习题答案(
- Beyond Software Architecture - Creating and Su
- 12 More Essential Skills for Software Architec
- 北邮大二上计算机系统基础.rar
评论
共有 条评论