logo Hurry, Grab up to 30% discount on the entire course
Order Now logo

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

expert
Rob RouseData mining
(5/5)

965 Answers

Hire Me
expert
Fiona EwinggPsychology
(5/5)

613 Answers

Hire Me
expert
Victor JordanEnglish
(5/5)

888 Answers

Hire Me
expert
Writer CenterAccounting
(5/5)

707 Answers

Hire Me
C Programming

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.

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