C programming and C programming Please explain every step”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’treallyimplement 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 , but now we’re going to storegeneric objectsin 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 implementreference countingand agarbage collector, so that we properly handle creation and deletion of objects. The object manager’s interface is given byObjectManager.hand the implementation you write will be in a file namedObjectManager.c. Your task is to implement the functions required for the object manager. This includes all the functions listed inObjectManager.h, along with any (private)staticfunctions 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 areNOTallowed to changeObjectManager.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 theaddressof an object, identified by the reference id.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 isNOTpart of the interface available to the client code. That is, it’s not declared inObjectManager.h, but you need to implement it and call it in your own implementation.dumpPool()- Print (tostdout) info about each object that is currently allocated including its id, start address, and size.Garbage collectionYou will implement a Mark and Sweep Defragmenting/Mark-compact garbage collector, as described in class. This function is implemented bycompact()in the object manager. So that we can evaluate your implementation, every time the garbage collector runs, print out the following statistics (tostdout):The number of objects that existThe current number of bytes in useThe number of bytes collectedData structuresYou 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 insideObjectManager.c, you don’t need any additional files likelist.{h,c}.Testing your Object ManagerYou will (eventually) be provided with several files (containing themain()function) for testing your object manager. You can start withmain0.con 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 arriveveryclose to the due date. If you wait until they’re available, there’s no way you’ll finish the assignment on time.ObjectManager.h/** Object Manager header file*///This is the interface for the object manager.//Note: The terms object and block are used interchangably below.#ifndef _OBJECT_MANAGER_H#define _OBJECT_MANAGER_H// The number of bytes of memory we have access to — put here so// everyone’s consistent.#ifndef MEMORY_SIZE#define MEMORY_SIZE 1024*512#endif#define NULL_REF 0typedef unsigned long Ref;typedef unsigned long ulong;typedef unsigned char uchar;/** Note that we provide our entire interface via this object module* and completely hide our index (see course notes). This allows us to* change indexing strategies without affecting the interface to* everyone else.* This function trys to allocate a block of given size from our buffer.* It will fire the garbage collector as required.* We always assume that an insert always creates a new object…* On success it returns the reference number for the block of memory* allocated for the object.* On failure it returns NULL_REF (0)*/Ref insertObject( ulong size );// returns a pointer to the object being requested given by the reference idvoid *retrieveObject( Ref ref );// update our index to indicate that we have another reference to the given objectvoid addReference( Ref ref );// update our index to indicate that a reference is gonevoid dropReference( Ref ref );// initialize the object managervoid initPool();// clean up the object manager (before exiting)void destroyPool();/** This function traverses the index and prints the info in each entry* corresponding to a block of allocated memory. You should print the* block’s reference id, its starting address, and its size (in* bytes).*/void dumpPool();#endifmain0.c/** main0.c*/#include “ObjectManager.h”#include int main(int argc, char *argv[]){char *ptr;int i;Ref id1,id2,id3;initPool();id1= insertObject(100);printf(“id1 = %lun”, id1);ptr = (char*)retrieveObject(id1);for (i = 0; i < 100; i)ptr[i] = (char)(i%26 'A');id2 = insertObject(4000);id3 = insertObject(20200);dropReference(id3);addReference(id2);id3 = insertObject(10);ptr = (char*)retrieveObject(id1);for (i = 0; i < 100; i)fprintf(stdout,"%c",ptr[i]);fprintf(stdout,"n");dumpPool();destroyPool();fprintf(stdout,"---n");return 0;}Computer Science Engineering & Technology C Programming COMP 2160

Order your essay today and save 20% with the discount code ESSAYHELP