1 / 6

Programming Languages (CS 550) List Processing, Dynamic Memory Allocation and Garbage Collection

This lecture explores list processing, dynamic memory allocation, and garbage collection. We will review list processing functions, discuss list primitives and functions, and learn about garbage collection techniques. Additionally, we will extend the Mini Language to support lists and implement a Mark & Sweep Garbage Collection algorithm.

leroyg
Download Presentation

Programming Languages (CS 550) List Processing, Dynamic Memory Allocation and Garbage Collection

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Programming Languages (CS 550)List Processing, Dynamic Memory Allocation and Garbage Collection Jeremy R. Johnson

  2. Theme • This lecture reviews list processing discusses dynamic memory allocation and garbage collection. • This will allow us to re-implement the list version of the mini language without relying on underlying support for lists. Rather than force the user to explicitly free memory, we will use garbage collection to reclaim unused memory.

  3. Outline • Go over last week’s practice exercises • Review list processing functions • List primitives – (), cons, car, cdr, pair?, null? • List functions – length, append, reverse, reduce, map, order

  4. Outline • cons cells and list allocation (uniform size) • List diagrams and list cells • Overlapping list cells and extent • Reference counting • Heap • Garbage Collection • Mark and Sweep • variable size allocation • First-fit • Next-fit • Best-fit

  5. Assignment 4 (Part I • Extend Mini Language and Mini Lang Interpreter • Add lists to the mini language • Values are now lists or ints (modify Environment) • Support list constants and built-in list processing functions • cons( e, L ) - appends element e to the front of list • car( L ) - returns the first element in the list • cdr( L ) - returns the rest of the list (minus the first element) • nullp( L ) - returns 1 if L is null, 0 otherwise • intp( e ) - returns 1 if e is an integer, 0 otherwise • listp( e ) - returns 1 if e is a list, 0 otherwise to allow construction and access to lists.

  6. Assignment 4 Part II • Re-implement (mini language with lists) • Allocate cells through cons from a Heap (an array of cells) • Implement Mark & Sweep Garbage Collection • Use symbol table to detect active list variables • Need to be careful with temporary variables used for list constants

More Related