Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

you will b implmnting a mmory allocator for th hap of a usr-lvl procss. **(Must be done in C no C++) done use malloc you

you will b implmnting a mmory allocator for th hap of a usr-lvl procss.

**(Must be done in C no C++) done use malloc

you must us mmap() . Scond, although a ral mmory allocator rqusts mor mmory from th OS whnvr it can't satisfy a rqust from th usr, your mmory allocator must call mmap() only on tim (whn it is first initializd).

Classic malloc() and fr() ar dfind as follows:

void *malloc(siz_t siz): malloc() allocats siz byts and rturns a pointr to th allocatd mmory. Th mmory is not clard.

void fr(void *ptr): fr() frs th mmory spac pointd to by ptr, which must hav bn rturnd by a prvious call to malloc() (or calloc() or ralloc()). Othrwis, or if fr(ptr) has alrady bn calld bfor, undfind bhaviour occurs. If ptr is NULL, no opration is prformd.

must align rqusts on 16-byt addrsss.

Th program will nd to maintain data structurs that minimally kp track of blocks of fr spac. Ths data structurs should ***NOT*** b in th allocatd pags thmslvs.

If th usr frs two blocks of mmory that ar adjacnt, your program should coalsc thm.

If th usr attmpts to allocat mor spac than is availabl in an opn fr block, thn malloc_alloc should rturn NULL.

void malloc_init(int num_pags_for_hap){

int pagsiz;

pagsiz = gtpagsiz();

void *ptr;

ptr = mmap(NULL, pagsiz, add flag hr, -1, 0);

rturn;

}

void *malloc_alloc(int num_byts_allocat){

rturn NULL;

}

void malloc_fr(void *pointr_ara_to_fr){

rturn;

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Theory And Application Bio Science And Bio Technology International Conferences DTA And BSBT 2011 Held As Part Of The Future Generation In Computer And Information Science 258

Authors: Tai-hoon Kim ,Hojjat Adeli ,Alfredo Cuzzocrea ,Tughrul Arslan ,Yanchun Zhang ,Jianhua Ma ,Kyo-il Chung ,Siti Mariyam ,Xiaofeng Song

2011th Edition

3642271561, 978-3642271564

Students also viewed these Databases questions

Question

=+6. What is the main advantage of this tactic?

Answered: 1 week ago

Question

Challenges Facing Todays Organizations?

Answered: 1 week ago