logo Use CA10RAM to get 10%* Discount.
Order Nowlogo
(5/5)

You will implement a Mark and Sweep Defragmenting/Mark-compact garbage collector, as described in class. This function is implemented by compact() in the object manager.

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

Question 1: The Object Manager

Summary

“Hey!” I can hear you saying. “You said we were going to implement a garbage collector, but now you’re talking about an ‘object manager’? What’s the deal?”

Here’s the deal: We can’t really implement garbage collection in C without changing the language itself. That’s why we have languages like Java, and Go, and C#, and D, and Python, that all have garbage collection built into the language itself.

An object manager is an application of the collection ADT (like in A3), but now we’re going to store generic objects in a managed buffer. That is, our container is going to be able to hold any kind of object we want and won’t be limited to just strings. Using a buffer means that we must directly manage the memory and references to objects. This means that our object manager must implement reference counting and a garbage collector, so that we properly handle creation and deletion of objects. The object manager’s interface is given by ObjectManager.h and the implementation you write will be in a file named ObjectManager.c. Your task is to implement the functions required for the object manager. This includes all the functions listed in ObjectManager.h, along with any (private) static functions that will be useful. You will also need to define appropriate data types and data structures for keeping track of the objects that have been allocated. You are NOT allowed to change ObjectManager.h. To summarize, the functionalities you have to implement are:

initPool() – Initialize the object manager upon starting.

destroyPool() – Clean up the object manager upon quitting.

insertObject(size) – Request a block of memory of given size from the object manager.

retrieveObject(id) – Retrieve the address of an object, identified by the reference

addReference(id) – Increment the reference count for the object with reference id. dropReference(id) – Decrement the reference count for the object with reference id.

compact() – Initiate garbage collection (see below). Note this function is NOT part

of the interface available to the client code. That is, it’s not declared in ObjectManager.h, but you need to implement it and call it in your own implementation.

dumpPool() – Print (to stdout) info about each object that is currently allocated including its id, start address, and size.

Garbage collection

You will implement a Mark and Sweep Defragmenting/Mark-compact garbage collector, as described in class. This function is implemented by compact() in the object manager. So that we can evaluate your implementation, every time the garbage collector runs, print out the following statistics (to stdout):

The number of objects that exist The current number of bytes in use The number of bytes collected

Data structures

You must manage the tracking of allocated objects using an index, which will be implemented using a linked list. Each node in your linked list contains the information needed to manage its associated object. Note that the index is implemented inside ObjectManager.c, you don’t need any additional files like list.{h,c}.

Testing your Object Manager

You will (eventually) be provided with several files (containing the main() function) for testing your object manager. You can start with main0.c on the course website.

In the meantime, you’ll have to use some of your new found testing and debugging skills to ensure you code can handle anything a program may throw at it. At minimum, the code you hand in should apply the concepts of DbC, as required in A2 and A3. Note that the main files will arrive very close to the due date. If you wait until they’re available, there’s no way you’ll finish the assignment on time.

Other comments

Try to start the assignment as soon as possible

Test each feature as it is implemented. Create your own test cases to test your code.

You will have multiple files, so a Makefile is required. You only need to include a rule for main.c so that you and the grader can swap in different main files by renaming and touching the file.

(5/5)
Attachments:

Related Questions

. Introgramming & Unix Fall 2018, CRN 44882, Oakland University Homework Assignment 6 - Using Arrays and Functions in C

DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma

. The standard path finding involves finding the (shortest) path from an origin to a destination, typically on a map. This is an

Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t

. 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. The LineItem class will represent an individual

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

. SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

. Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

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

expert
Um e HaniScience

552 Answers

Hire Me
expert
Muhammad Ali HaiderFinance

880 Answers

Hire Me
expert
Husnain SaeedComputer science

603 Answers

Hire Me
expert
Atharva PatilComputer science

516 Answers

Hire Me