gclab - CS2400 Fall 2010 GC Lab Writing a Garbage...

Info icon This preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
CS2400, Fall 2010 GC Lab: Writing a Garbage Collecting Storage Allocator 1 Introduction In this lab you will be writing a garbage collector for a hypothetical programming language. Garbage collection is described in § 9.10 of the textbook; it’s used in many languages such as Java, C#, and so on. Our implementation is designed for a computer with a 32-bit address space – i.e. one where the the size of a pointer is four bytes. 2 Logistics You may work in a group of up to two people. Any clarifications and revisions to the assignment will be posted on the course Moodle. 3 Hand Out Instructions Download the gclab-handout.tar file from the Moodle assignment page. Start by copying gclab-handout.tar to a protected directory in which you plan to do your work. Then give the command: tar xvf gclab-handout.tar . This will cause a number of files to be unpacked into the directory. The only file you must modify and hand in is gc.c ; however, you have the option of changing other files as we’ll describe later. The test-list.c , etc programs are program that allows you to evaluate the correctness and performance of your solution. Use the command make to generate the test programs and run them with the command ./test-list , etc or the RUN command. Looking at the file gc.c you’ll notice a C structure team into which you should insert the requested identifying information about the one or two individuals comprising your programming team. Do this right away so you don’t forget. When you have completed the lab, you will hand in a zip or tar file containing all the components your solution depends on. 1
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
4 How to Work on the Lab Your dynamic garbage collector will consist of the following three functions, which are declared in gc.h and defined in gc.c . int gc_init(void); void * gc_alloc(gc_type_info * ); void * gc_collect(); The gc.c file we have given provide some “scaffolding” to implement a memory allocator, but it does not function by itself. Using this as a starting place, modify these functions (and possibly define other private static functions), so that they obey the following semantics: gc init: Before calling gc alloc function the application program (i.e., the test programs that you will use to evaluate your implementation) calls gc init to perform any necessary initializations, such as allocating the initial heap area. gc alloc: The gc alloc routine returns a pointer to an allocated block payload sufficiently large to accommodate the object type described via a pointer to an instance of gc_type_info . The entire allocated block should lie within the heap region and should not overlap with any other allocated chunk. The address of the allocated block should be aligned to an 8-byte memory address ( i.e. the lower 3 bits of the returned address should be zero). I describe more of the use of gc_type_info below.
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern