logo Use SA10RAM to get 10%* Discount.
Order Now logo

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Allen CrumpStatistics
(5/5)

825 Answers

Hire Me
expert
Connor EvanssEconomics
(5/5)

763 Answers

Hire Me
expert
Rameshwar DassHistory
(5/5)

564 Answers

Hire Me
expert
StatAnalytica ExpertGeneral article writing
(5/5)

722 Answers

Hire Me
C Programming

Implement your own memory manager using the Buddy Algorithm. You should use the mmap() system call to initially allocate a large block of memory. 

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

Buddy System Memory Management

Implement your own memory manager using the Buddy Algorithm. You should use the mmap() system call to initially allocate a large block of memory.  A good initial amount is 512MB. From there on, manage the chunk of memory returned by mmap using your own memory management functions.

 

Note that you will have to store the data structures used to represent the buddy system somewhere in memory. You may statically declare these pointers in your code (in the data segment). For this purpose you may assume that the maximum amount of memory that you will ever manage is limited to 32GB. 

 

The beginning of each block should contain a block_header (defined in buddy.c) that maintains the “metadata” for the current block of memory.  This structure includes the TAG field described in the “Buddy System” algorithm by Knuth.

 

Your library should be initialized in a function named buddy_init.  If the user doesn't call this function, then it is transparently called whenever the user calls the buddy_malloc buddy_calloc for the first time. You can test for that using a static variable.

 

Note that if a 0 is passed as an argument to buddy_init, then it initializes the memory pool to be of the default size (512MB, as specified above).  If the caller specifies an unreasonably small size, then the buddy system may not be able to satisfy any requests.

 

If the memory cannot be allocated, then your buddy_calloc or buddy_malloc functions should set errno to ENOMEM (which is defined in errno.h header file) and return NULL.

 

The starter files include a buddy.h header file that contains all the declarations and prototypes. They also include a skeleton buddy.c that has the declaration for the pool and the table of lists for the buddy system.

 

  • Implement buddy_init() as described in buddy.h. The return codes of any library or system calls made in your library related to this method must be checked and validated to prevent segmentation faults.

  • Implement buddy_malloc() as described in buddy.h. See the testing hints below for several use cases your write method should be able to handle without segfaults. The return codes of any library or system calls  made in your library related to this method must be checked and validated to prevent segmentation faults. 

  • Implement buddy_calloc() as described in buddy.h. The return codes of any library or system calls made in your library related to this method must be checked and validated to prevent segmentation faults.

  • Implement buddy_realloc() as described in buddy.h. The return codes of any library or system calls made in your library related to this method must be checked and validated to prevent segmentation faults.

  • Implement buddy_free() as described in buddy.h. The return codes of any library or system calls made in your library related to this method must be checked and validated to prevent segmentation faults.

  • Fully test your buddy implementation using the provided unit tests. This will require implementation of the print_buddy_lists(), get_max_kval() and get_min_kval() functions provided in buddy.h

Testing

Library Tests

We have provided a set of unit tests in buddy-unit-test.c that checks a number of boundary cases in the buddy memory manager. The buddy-unit-test tool includes tests that are not on the “safe path”, meaning that it tries to do things that it expects to fail. Don’t be too disheartened if not all the tests pass on the first pass. The bulk of the work on this project begins once you start testing.

Related Questions

. The fundamental operations of create, read, update, and delete (CRUD) in either Python or Java

CS 340 Milestone One Guidelines and Rubric  Overview: For this assignment, you will implement the fundamental operations of create, read, update,

. Develop a program to emulate a purchase transaction at a retail store. This  program will have two classes, a LineItem class and a Transaction class

Retail Transaction Programming Project  Project Requirements:  Develop a program to emulate a purchase transaction at a retail store. This

. The following program contains five errors. Identify the errors and fix them

7COM1028   Secure Systems Programming   Referral Coursework: Secure

. Accepts the following from a user: Item Name Item Quantity Item Price Allows the user to create a file to store the sales receipt contents

Create a GUI program that:Accepts the following from a user:Item NameItem QuantityItem PriceAllows the user to create a file to store the sales receip

. The final project will encompass developing a web service using a software stack and implementing an industry-standard interface. Regardless of whether you choose to pursue application development goals as a pure developer or as a software engineer

CS 340 Final Project Guidelines and Rubric  Overview The final project will encompass developing a web service using a software stack and impleme

Get Free Quote!

380 Experts Online