资源简介
哈工大计算机系统实验八动态内存分配器 实验报告和代码
代码片段和文件信息
/*
* 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 */
“weixiaowen“
/* First member‘s full name */
“weixiaowen“
/* First member‘s email address */
“706461857@qq.com“
/* Second member‘s full name (leave blank if none) */
““
/* Second member‘s email address (leave blank if none) */
““
};
/* $begin mallocmacros */
/* Basic constants and macros */
#define WSIZE 4 /* word size (bytes) */
#define DSIZE 8 /* doubleword size (bytes) */
#define CHUNKSIZE (1<<12) /* initial heap size (bytes) */
#define OVERHEAD 8 /* overhead of header and footer (bytes) */
#define MAX(x y) ((x) > (y)? (x) : (y))
/* Pack a size and allocated bit into a word */
#define PACK(size alloc) ((size) | (alloc))
/* Read and write a word at address p */
#define GET(p) (*(size_t *)(p))
#define PUT(p val) (*(size_t *)(p) = (val))
/* Read the size and allocated fields from address p */
#define GET_SIZE(p) (GET(p) & ~0x7)
#define GET_ALLOC(p) (GET(p) & 0x1)
/* Given block ptr bp compute address of its header and footer */
#define HDRP(bp) ((char *)(bp) - WSIZE)
#define FTRP(bp) ((char *)(bp) + GET_SIZE(HDRP(bp)) - DSIZE)
/* Given block ptr bp compute address of next and previous blocks */
#define NEXT_BLKP(bp) ((char *)(bp) + GET_SIZE(((char *)(bp) - WSIZE)))
#define PREV_BLKP(bp) ((char *)(bp) - GET_SIZE(((char *)(bp) - DSIZE)))
/* $end mallocmacros */
/* Global variables */
static char *heap_listp; /* pointer to first block */
#ifdef NEXT_FIT
static char *rover; /* next fit rover */
#endif
/* function prototypes for internal helper routines */
static void *extend_heap(size_t words);
static void place(void *bp size_t asize);
static void *find_fit(size_t asize);
static void *coalesce(void *bp);
static void printblock(void *bp);
static void checkblock(void *bp);
/*
* mm_init - Initialize the memory manager
*/
/* $begin mminit */
int mm_init(void)
{
/* create the initial empty heap */
if ((heap_listp = mem_sbrk(4*WSIZE)) == NULL)
return -1;
PUT(heap_listp 0); /* alignment padding */
PUT(heap_listp+WSIZE P
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 792556 2018-12-24 23:14 计算机系统1170500704魏孝文\1170500704魏孝文.pdf
文件 273920 2018-12-24 23:13 计算机系统1170500704魏孝文\HITICS-lab8实验报告1170500704魏孝文.doc
文件 9356 2018-12-11 21:23 计算机系统1170500704魏孝文\mm.c
目录 0 2018-12-25 21:26 计算机系统1170500704魏孝文
----------- --------- ---------- ----- ----
1075832 4
相关资源
- 哈工大计算机系统实验PPT
- RFC4838 Delay-Tolerant Networking Architecture
- 深入理解计算机系统 CSAPP原书第三版
- csapp arch lab 满分原创北大&cmu; 全集
- csapp proxy lab 满分原创北大&cmu; 仅供
- csapp malloc lab 原创北大&cmu; 仅供参考
- Saas架构和权限设计
- 5G大规模天线Massive MIMO技术介绍1-GTI
- csapp.h csapp.c文件
- ibm rational rsa 9.5最新版本完美破解
- CSAPPLAB2实验报告
- SysML and Rhapsody WhitePape
- 亚马逊云服务AWS Certified Solutions Arch
- csapp cache lab 满分原创北大&cmu; 仅供参
- Lora 安全白皮书
- 2018年全国大学生计算机技能应用大赛
- xiaotao_hit_10366747.zip
- vxworks_for_mips_architecture_supplement_6.1
- csapp mountain.tar 存储山
- 深入理解计算机系统真题
- 中科大csapp实验4 perflab-handout 代码优化
- Hitachi AMS 2100 2300存储控制单元/控制器
- OMG Model Driven Architecture (MDA) MDA Gu
- CSAPP: shell lab 解答
- AWS Solution Architect Certificate
- computer arithmetic: principles architectures
- 南京大学CSAPP lab5-9
- csapp中文第三版pdf(深入理解计算机操
- HITRAN氧气数据库
- Atmel Microcontroller 8051 Architecture_201408
评论
共有 条评论