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.
CS 340 Milestone One Guidelines and Rubric Overview: For this assignment, you will implement the fundamental operations of create, read, update,
Retail Transaction Programming Project Project Requirements: Develop a program to emulate a purchase transaction at a retail store. This
7COM1028 Secure Systems Programming Referral Coursework: Secure
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
CS 340 Final Project Guidelines and Rubric Overview The final project will encompass developing a web service using a software stack and impleme