malloclab-handout(99점과 100점짜리 소스입니다)
*준*
다운로드
장바구니
소개글
malloclab-handoutmalloc 100점과 99점 짜리 구현 소스 두개 올립니다.
공부에 도움이 되셨으면 합니다.
예전꺼라 기억이 가물가물 하지만 어째든 정말 잘 돌아갑니다
열공하세요 ^^
목차
1 Introduction2 Logistics
3 Hand Out Instructions
4 How to Work on the Lab
5 Support Routines
6 The Trace-driven Driver Program
7 Programming Rules
8 Evaluation
9 Handin Instructions
10 Hints
11 More Hints
본문내용
#include <assert.h>#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <dlfcn.h>
#include "mm.h"
#include "memlib.h"
#ifdef DRIVER
#define malloc mm_malloc
#define free mm_free
#define realloc mm_realloc
#define calloc mm_calloc
#endif
#define WSIZE 4
#define OVERHEAD 8
#define DSIZE 8
#define PACK(size,alloc) ((size)|(alloc))
#define GET(p) (*(size_t *)(p))
#define PUT(p, val) (*(size_t *)(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 FLSB(bp) ((char *)(bp) )
#define FLPB(bp) ((char *)(bp) + WSIZE)
#define NEXT_BLKP(bp) ((char *)(bp) + GET_SIZE(((char *)(bp) - WSIZE)))
#define PREV_BLKP(bp) ((char *)(bp) - GET_SIZE(((char *)(bp) - DSIZE)))
#define AD(bp) ( ( (char*)bp - start)/8)
void extend(size _t asize);
void place(void *bp,size_t asize);
void *malloc(size_t size);
static void find_fit(size_t asize);
static void merge(void *bp , size_t size, int state);
static void free(void *bp);
static void merge_case(void *bp,int state);
void *init; //list
void *last; //last
void *start;
int free_count;
//Init
int mm_init(void)
{
start = mem_sbrk(0);
free_count = 0;
init = NULL;
bp = mem_sbrk(DSIZE*4);
PUT(HDRP(bp),PACK(DSIZE*2,1));
PUT(FTRP(bp),PACK(DSIZE*2,1));
bp = NEXT_BLKP(bp);
last = bp;
PUT(HDRP(bp),PACK(DSIZE*2,1));
PUT(FTRP(bp),PACK(DSIZE*2,1));
}
void *malloc(size_t size)
{
while(1)
{
if( free_count ) //exist
{
if ( bp = find_fit(asize) )
return place(bp,asize);
else
extend(asize);
}
else
extend(asize);
}
}
참고 자료
없음압축파일 내 파일목록
malloclab-handout99/-l
malloclab-handout99/clock.c
malloclab-handout99/clock.h
malloclab-handout99/clock.o
malloclab-handout99/config.h
malloclab-handout99/fcyc.c
malloclab-handout99/fcyc.h
malloclab-handout99/fcyc.o
malloclab-handout99/fsecs.c
malloclab-handout99/fsecs.h
malloclab-handout99/fsecs.o
malloclab-handout99/ftimer.c
malloclab-handout99/ftimer.h
malloclab-handout99/ftimer.o
malloclab-handout99/Makefile
malloclab-handout99/malloc.c
malloclab-handout99/malloclab.pdf
malloclab-handout99/malloclab.ps
malloclab-handout99/mdriver
malloclab-handout99/mdriver.c
malloclab-handout99/mdriver.o
malloclab-handout99/memlib.c
malloclab-handout99/memlib.h
malloclab-handout99/memlib.o
malloclab-handout99/mm-helper.c
malloclab-handout99/mm-naive.c
malloclab-handout99/mm-orig.c
malloclab-handout99/mm.c
malloclab-handout99/mm.c,v
malloclab-handout99/mm.cbp
malloclab-handout99/mm.h
malloclab-handout99/mm.o
malloclab-handout99/mm_backup.c
malloclab-handout99/mm_sucess.c
malloclab-handout99/mm_view.c
malloclab-handout99/mm_view_1.c
malloclab-handout99/mm_view_2.c
malloclab-handout99/nn_fail.c
malloclab-handout99/README
malloclab-handout99/test
malloclab-handout99/test.txt
malloclab-handout99/traces/amptjp-bal.rep
malloclab-handout99/traces/binary-bal.rep
malloclab-handout99/traces/binary2-bal.rep
malloclab-handout99/traces/cccp-bal.rep
malloclab-handout99/traces/coalescing-bal.rep
malloclab-handout99/traces/corners.rep
malloclab-handout99/traces/cp-decl-bal.rep
malloclab-handout99/traces/expr-bal.rep
malloclab-handout99/traces/hostname.rep
malloclab-handout99/traces/malloc-free.rep
malloclab-handout99/traces/malloc.rep
malloclab-handout99/traces/mutt.rep
malloclab-handout99/traces/perl.rep
malloclab-handout99/traces/random-bal.rep
malloclab-handout99/traces/random2-bal.rep
malloclab-handout99/traces/test.rep
malloclab-handout99/traces/xterm.rep
malloclab-handout100/-l
malloclab-handout100/clock.c
malloclab-handout100/clock.h
malloclab-handout100/clock.o
malloclab-handout100/config.h
malloclab-handout100/fcyc.c
malloclab-handout100/fcyc.h
malloclab-handout100/fcyc.o
malloclab-handout100/fsecs.c
malloclab-handout100/fsecs.h
malloclab-handout100/fsecs.o
malloclab-handout100/ftimer.c
malloclab-handout100/ftimer.h
malloclab-handout100/ftimer.o
malloclab-handout100/Makefile
malloclab-handout100/malloc.c
malloclab-handout100/malloclab.pdf
malloclab-handout100/malloclab.ps
malloclab-handout100/mdriver
malloclab-handout100/mdriver.c
malloclab-handout100/mdriver.o
malloclab-handout100/memlib.c
malloclab-handout100/memlib.h
malloclab-handout100/memlib.o
malloclab-handout100/mm-helper.c
malloclab-handout100/mm-naive.c
malloclab-handout100/mm-orig.c
malloclab-handout100/mm.c
malloclab-handout100/mm.c,v
malloclab-handout100/mm.cbp
malloclab-handout100/mm.h
malloclab-handout100/mm.o
malloclab-handout100/mm_backup.c
malloclab-handout100/mm_sucess.c
malloclab-handout100/mm_view.c
malloclab-handout100/mm_view_1.c
malloclab-handout100/mm_view_2.c
malloclab-handout100/nn_fail.c
malloclab-handout100/README
malloclab-handout100/test.txt
malloclab-handout100/traces/amptjp-bal.rep
malloclab-handout100/traces/binary-bal.rep
malloclab-handout100/traces/binary2-bal.rep
malloclab-handout100/traces/cccp-bal.rep
malloclab-handout100/traces/coalescing-bal.rep
malloclab-handout100/traces/corners.rep
malloclab-handout100/traces/cp-decl-bal.rep
malloclab-handout100/traces/expr-bal.rep
malloclab-handout100/traces/hostname.rep
malloclab-handout100/traces/malloc-free.rep
malloclab-handout100/traces/malloc.rep
malloclab-handout100/traces/mutt.rep
malloclab-handout100/traces/perl.rep
malloclab-handout100/traces/random-bal.rep
malloclab-handout100/traces/random2-bal.rep
malloclab-handout100/traces/test.rep
malloclab-handout100/traces/xterm.rep
malloclab-handout99/clock.c
malloclab-handout99/clock.h
malloclab-handout99/clock.o
malloclab-handout99/config.h
malloclab-handout99/fcyc.c
malloclab-handout99/fcyc.h
malloclab-handout99/fcyc.o
malloclab-handout99/fsecs.c
malloclab-handout99/fsecs.h
malloclab-handout99/fsecs.o
malloclab-handout99/ftimer.c
malloclab-handout99/ftimer.h
malloclab-handout99/ftimer.o
malloclab-handout99/Makefile
malloclab-handout99/malloc.c
malloclab-handout99/malloclab.pdf
malloclab-handout99/malloclab.ps
malloclab-handout99/mdriver
malloclab-handout99/mdriver.c
malloclab-handout99/mdriver.o
malloclab-handout99/memlib.c
malloclab-handout99/memlib.h
malloclab-handout99/memlib.o
malloclab-handout99/mm-helper.c
malloclab-handout99/mm-naive.c
malloclab-handout99/mm-orig.c
malloclab-handout99/mm.c
malloclab-handout99/mm.c,v
malloclab-handout99/mm.cbp
malloclab-handout99/mm.h
malloclab-handout99/mm.o
malloclab-handout99/mm_backup.c
malloclab-handout99/mm_sucess.c
malloclab-handout99/mm_view.c
malloclab-handout99/mm_view_1.c
malloclab-handout99/mm_view_2.c
malloclab-handout99/nn_fail.c
malloclab-handout99/README
malloclab-handout99/test
malloclab-handout99/test.txt
malloclab-handout99/traces/amptjp-bal.rep
malloclab-handout99/traces/binary-bal.rep
malloclab-handout99/traces/binary2-bal.rep
malloclab-handout99/traces/cccp-bal.rep
malloclab-handout99/traces/coalescing-bal.rep
malloclab-handout99/traces/corners.rep
malloclab-handout99/traces/cp-decl-bal.rep
malloclab-handout99/traces/expr-bal.rep
malloclab-handout99/traces/hostname.rep
malloclab-handout99/traces/malloc-free.rep
malloclab-handout99/traces/malloc.rep
malloclab-handout99/traces/mutt.rep
malloclab-handout99/traces/perl.rep
malloclab-handout99/traces/random-bal.rep
malloclab-handout99/traces/random2-bal.rep
malloclab-handout99/traces/test.rep
malloclab-handout99/traces/xterm.rep
malloclab-handout100/-l
malloclab-handout100/clock.c
malloclab-handout100/clock.h
malloclab-handout100/clock.o
malloclab-handout100/config.h
malloclab-handout100/fcyc.c
malloclab-handout100/fcyc.h
malloclab-handout100/fcyc.o
malloclab-handout100/fsecs.c
malloclab-handout100/fsecs.h
malloclab-handout100/fsecs.o
malloclab-handout100/ftimer.c
malloclab-handout100/ftimer.h
malloclab-handout100/ftimer.o
malloclab-handout100/Makefile
malloclab-handout100/malloc.c
malloclab-handout100/malloclab.pdf
malloclab-handout100/malloclab.ps
malloclab-handout100/mdriver
malloclab-handout100/mdriver.c
malloclab-handout100/mdriver.o
malloclab-handout100/memlib.c
malloclab-handout100/memlib.h
malloclab-handout100/memlib.o
malloclab-handout100/mm-helper.c
malloclab-handout100/mm-naive.c
malloclab-handout100/mm-orig.c
malloclab-handout100/mm.c
malloclab-handout100/mm.c,v
malloclab-handout100/mm.cbp
malloclab-handout100/mm.h
malloclab-handout100/mm.o
malloclab-handout100/mm_backup.c
malloclab-handout100/mm_sucess.c
malloclab-handout100/mm_view.c
malloclab-handout100/mm_view_1.c
malloclab-handout100/mm_view_2.c
malloclab-handout100/nn_fail.c
malloclab-handout100/README
malloclab-handout100/test.txt
malloclab-handout100/traces/amptjp-bal.rep
malloclab-handout100/traces/binary-bal.rep
malloclab-handout100/traces/binary2-bal.rep
malloclab-handout100/traces/cccp-bal.rep
malloclab-handout100/traces/coalescing-bal.rep
malloclab-handout100/traces/corners.rep
malloclab-handout100/traces/cp-decl-bal.rep
malloclab-handout100/traces/expr-bal.rep
malloclab-handout100/traces/hostname.rep
malloclab-handout100/traces/malloc-free.rep
malloclab-handout100/traces/malloc.rep
malloclab-handout100/traces/mutt.rep
malloclab-handout100/traces/perl.rep
malloclab-handout100/traces/random-bal.rep
malloclab-handout100/traces/random2-bal.rep
malloclab-handout100/traces/test.rep
malloclab-handout100/traces/xterm.rep