首页
网站开发
桌面应用
管理软件
微信开发
App开发
嵌入式软件
工具软件
数据采集与分析
其他
首页
>
> 详细
ECE 650编程讲解、辅导C/C++程序语言、c++程序设计调试 解析Haskell程序|辅导Web开发
项目预算:
开发周期:
发布时间:
要求地区:
Assignment #1: Malloc Library Part 1
ECE 650 – Spring 2021
See course site for due date
General Instructions
1. You will work individually on this the project.
2. The code for this assignment should be developed and tested in a UNIX-based
environment. You can use the VM that has been made available to you for ECE551.
3. You must follow this assignment specs carefully, and turn in everything that is asked
(and in the proper formats, as described).
4. You should plan to start early on this project and make steady progress over time. It will
take time and careful though to work through the assignment.
Implementation of malloc library
For this assignment, you will implement your own version of several memory allocation
functions from the C standard library (actually you will have the chance to implement and study
several different versions as described below). Your implementation is to be done in C code.
The C standard library includes 4 malloc-related library functions: malloc(), free(),
calloc(), and realloc(). In this assignment, you only need to implement versions of
malloc() and free():
void * malloc(size_t size);
void free(void *ptr);
Please refer to the man pages for full descriptions of the expected operation for these
functions. Essentially, malloc() takes in a size (number of bytes) for a memory allocation,
locates an address in the program’s data region where there is enough space to fit the specified
number of bytes, and returns this address for use by the calling program. The free() function
takes an address (that was returned by a previous malloc operation) and marks that data
region as available again for use.
The submission instructions at the end of this assignment description provide specific details
about what code files to create, what to name your new versions of the malloc functions, etc.
As you work through implementing malloc() and free(), you will discover that as memory
allocations and deallocations happen, you will sometimes free a region of memory that is
adjacent to other also free memory region(s). Your implementation is required to coalesce in
this situation by merging the adjacent free regions into a single free region of memory.
Hint: For implementing malloc(), you should become familiar with the sbrk() system call.
This system call is useful for: 1) returning the address that represents the current end of the
processes data segment (called program break), and 2) growing the size of the processes data
segment by the amount specified by “increment”.
void *sbrk(intptr_t increment);
Hint: A common way to implement malloc() / free() and manage the memory space is to
keep an adequate data structure to represent a list of free memory regions. This collection of
free memory ranges would change as malloc() and free() are called to allocate and
release regions of memory in the process data segment. You may design and implement your
malloc and free using structures and state tracking as you see best fit.
In this assignment, you will develop a malloc implementation and study different allocation
policies.
Study of Memory Allocation Policies
Your task is to implement 2 versions of malloc and free, each based on a different strategy
for determining the memory region to allocate. The two strategies are:
1. First Fit: Examine the free space tracker (e.g. free list), and allocate an address from
the first free region with enough space to fit the requested allocation size.
2. Best Fit: Examine all of the free space information, and allocate an address from the
free region which has the smallest number of bytes greater than or equal to the
requested allocation size.
The following picture illustrates how each strategy would operate (assuming free regions are
traversed in a left to right order) for a malloc() request of 2 bytes:
Requirements: Malloc implementations
To implement your allocation strategies, you will create 4 functions:
//First Fit malloc/free
void * ff_malloc(size_t size);
void ff_free(void * ptr);
//Best Fit malloc/free
void * bf_malloc(size_t size);
void bf_free(void * ptr);
Note, that in all cases, a policy to minimize the size of the process’s data segment should be
used. In other words, if there is no free space that fits an allocation request, then sbrk()
should be used to create that space. However, you do not need to perform any type of garbage
collection (e.g. reducing the size of the process’s data segment, even if allocations at the top of
the data segment have been freed).
On free(), your implementation is required to merge the newly freed region with any currently
free adjacent regions. In other words, your bookkeeping data structure should not contain
multiple adjacent free regions, as this would lead to poor region selection during malloc.
Requirement: Performance study report
In addition to implementing these malloc functions, you are tasked to conduct a performance
study of the malloc()with different allocation policies. Several programs for experimentation
will be provided that perform malloc() and free() requests with different patterns (e.g.
frequencies, sizes). The metrics of interest will be:
1) the run-time of the programs, as the implementation of different allocation policies may
result in different speeds of memory allocation;
2) the memory fragmentation is a number in the interval [0,1] (interpreted as a
percenbtage), which is measured as follows:
1 −(size of largest allocatable memory block/total size of free memory)
In order to capture #2, you should also implement two additional library functions:
unsigned long get_largest_free_data_segment_size();//in bytes
unsigned long get_total_free_size();//in bytes
Then, using these functions, you can use the included test programs as well as test programs of
your own creation to evaluate and compare the algorithms.
The Starter Kit
A starter kit is included in a file on Sakai: homework1-kit.tgz
This archive can be extracted using “tar xvzf homework1-kit.tgz”.
The kit includes:
Makefile: A sample Makefile for libmymalloc.so.
general_tests/: General correctness test, see README.txt for details.
alloc_policy_tests/: Allocation policy test cases, see README.txt for details.
alloc_policy_tests_osx/: Same thing adapted for MacOS.
NOTE: Mac OS is not the grading platform; these files are provided as a convenience.
Additionally, you may need to change #include "time.h" to #include "sys/time.h"
Testing your system
Code is provided for minimal testing, but the provided materials will not exhaustively evaluate
the correctness of your implementation. It is recommended to create your own test software that
uses your library, both to aid during development and to ensure correctness in a variety of
situations.
Detailed Submission Instructions
1. Please submit a written report called report.pdf to Sakai (a submission link will be
posted soon). The report should include an overview of how you implemented the
allocation policies, results from your performance experiments, and an analysis of the
results (e.g. why do you believe you observed the results that you did for different
policies with different malloc/free patterns, do you have recommendations for which
policy seems most effective, etc.).
2. Please submit a zipped file hw1_netID.zip to Sakai (e.g., if the netID is abc123, the
name of the file should be hw1_abc123.zip). All source code should be included in a
directory named “my_malloc”.
There should be a header file name “my_malloc.h” with the function definitions
for all *_malloc() and *_free() functions.
You may implement these functions in “my_malloc.c”. If you would like to use
different C source files, please describe what those are in the report.
There should be a “Makefile” which contains at least two targets: 1) “all” should
build your code into a shared library named “libmymalloc.so”, and 2) “clean”
should remove all files except for the source code files. The provided Makefile
may be used as-is, expanded upon, or replaced entirely. If you have not
compiled code into a shared library before, you should be able to find plenty of
information online. With this “Makefile” infrastructure, the test programs will be
able to: 1) #include “my_malloc.h” and 2) link against libmymalloc.so (-
lmymalloc), and then have access to the new malloc functions. Just like that, you
will have created your own version of the malloc routines in the C standard
library!
软件开发、广告设计客服
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-23:00
微信:codinghelp
热点项目
更多
urba6006代写、java/c++编程语...
2024-12-26
代做program、代写python编程语...
2024-12-26
代写dts207tc、sql编程语言代做
2024-12-25
cs209a代做、java程序设计代写
2024-12-25
cs305程序代做、代写python程序...
2024-12-25
代写csc1001、代做python设计程...
2024-12-24
代写practice test preparatio...
2024-12-24
代写bre2031 – environmental...
2024-12-24
代写ece5550: applied kalman ...
2024-12-24
代做conmgnt 7049 – measurem...
2024-12-24
代写ece3700j introduction to...
2024-12-24
代做adad9311 designing the e...
2024-12-24
代做comp5618 - applied cyber...
2024-12-24
热点标签
mktg2509
csci 2600
38170
lng302
csse3010
phas3226
77938
arch1162
engn4536/engn6536
acx5903
comp151101
phl245
cse12
comp9312
stat3016/6016
phas0038
comp2140
6qqmb312
xjco3011
rest0005
ematm0051
5qqmn219
lubs5062m
eee8155
cege0100
eap033
artd1109
mat246
etc3430
ecmm462
mis102
inft6800
ddes9903
comp6521
comp9517
comp3331/9331
comp4337
comp6008
comp9414
bu.231.790.81
man00150m
csb352h
math1041
eengm4100
isys1002
08
6057cem
mktg3504
mthm036
mtrx1701
mth3241
eeee3086
cmp-7038b
cmp-7000a
ints4010
econ2151
infs5710
fins5516
fin3309
fins5510
gsoe9340
math2007
math2036
soee5010
mark3088
infs3605
elec9714
comp2271
ma214
comp2211
infs3604
600426
sit254
acct3091
bbt405
msin0116
com107/com113
mark5826
sit120
comp9021
eco2101
eeen40700
cs253
ece3114
ecmm447
chns3000
math377
itd102
comp9444
comp(2041|9044)
econ0060
econ7230
mgt001371
ecs-323
cs6250
mgdi60012
mdia2012
comm221001
comm5000
ma1008
engl642
econ241
com333
math367
mis201
nbs-7041x
meek16104
econ2003
comm1190
mbas902
comp-1027
dpst1091
comp7315
eppd1033
m06
ee3025
msci231
bb113/bbs1063
fc709
comp3425
comp9417
econ42915
cb9101
math1102e
chme0017
fc307
mkt60104
5522usst
litr1-uc6201.200
ee1102
cosc2803
math39512
omp9727
int2067/int5051
bsb151
mgt253
fc021
babs2202
mis2002s
phya21
18-213
cege0012
mdia1002
math38032
mech5125
07
cisc102
mgx3110
cs240
11175
fin3020s
eco3420
ictten622
comp9727
cpt111
de114102d
mgm320h5s
bafi1019
math21112
efim20036
mn-3503
fins5568
110.807
bcpm000028
info6030
bma0092
bcpm0054
math20212
ce335
cs365
cenv6141
ftec5580
math2010
ec3450
comm1170
ecmt1010
csci-ua.0480-003
econ12-200
ib3960
ectb60h3f
cs247—assignment
tk3163
ics3u
ib3j80
comp20008
comp9334
eppd1063
acct2343
cct109
isys1055/3412
math350-real
math2014
eec180
stat141b
econ2101
msinm014/msing014/msing014b
fit2004
comp643
bu1002
cm2030
联系我们
- QQ: 9951568
© 2021
www.rj363.com
软件定制开发网!