Reference no: EM13963450
Reference Counting
This question is about a possible implementation of garbage collection for Lisp. Both impure and pure Lisp have lambda abstraction, function application, and elementary functions atom, eq, car, cdr, and cons. Impure Lisp also has rplaca, rplacd, and other functions that have side effects on memory cells.
Reference counting is a simple garbage-collection scheme that associates a refer- ence count with each datum in memory. When memory is allocated, the associated reference count is set to 0. When a pointer is set to point to a location, the count for that location is incremented. If a pointer to a location is reset or destroyed, the count for the location is decremented. Consequently, the reference count always tells how many pointers there are to a given datum. When a count reaches 0, the datum is considered garbage and is returned to the free-storage list. For example, after evaluation of (cdr (cons (cons 'A 'B) (cons 'C 'D))), the cell created for (cons 'A 'B) is garbage, but the cell for (cons 'C 'D) is not.
(a) Describe how reference counting could be used for garbage collection in eval- uating the following expression:
(car (cdr (cons (cons a b) (cons c d))))
where a, b, c, and d are previously de?ned names for cells. Assume that the reference counts for a, b, c,and d are initially set to some numbers greater than 0, so that these do not become garbage. Assume that the result of the entire expression is not garbage. How many of the three cons cells generated by the evaluation of this expression can be returned to the free-storage list?
(b) The "impure" Lisp function rplaca takes as arguments a cons cell c and a value v and modi?es c's address ?eld to point to v. Note that this operation does not produce a new cons cell; it modi?es the one it receives as an argument. The function rplacd performs the same function with respect the decrement portion of its argument cons cell.
Lisp programs that use rplaca or rplacd may create memory structures that cannot be garbage collected properly by reference counting. Describe a con?g- uration of cons cells that can be created by use of operations of pure Lisp and rplaca and rplacd. Explain why the reference-counting algorithm deos not work properly on this structure.
Heat capacity is an intensive quantity extensive quantity
: The heat capacity is defined as the amount of energy required to change the temperature of an object. The specific heat capacity is defined as the amount of energy required to change the temperature of an object per mole of the substance.
|
Complete the home painting
: Imagine that your neighbor contracts with a local house painter to have his house painted on Saturday. The contract calls for the painter to begin painting the home on Saturday at 8:00 a.m. and complete the home painting
|
Single-step income statement into a multiple-step
: single-step income statement into a multiple-step income statement for the month ended October 31, 2015. Income Statement For the year ended October
|
Describe the event the client experienced
: Create a mock case study of a client who is a survivor of a traumatic event and who has overcome the experience, and is now demonstrating resilience and overall wellbeing. Include and discuss the following concepts: Introduce the concept of resilie..
|
Problem regarding the reference counting
: This question is about a possible implementation of garbage collection for Lisp. Both impure and pure Lisp have lambda abstraction, function application, and elementary functions atom, eq, car, cdr, and cons. Impure Lisp also has rplaca, rplacd, a..
|
De?nition of garbage
: This question asks you to think about garbage collection in Lisp and compare our de?nition of garbage in the text to the one given in McCarthy's 1960 paper on Lisp. McCarthy's de?nition is written for Lisp speci?cally, whereas our de?nition is sta..
|
Description and symptoms of parkinson disease
: Provide a short description and the symptoms of Parkinson's disease or early detections, if any
|
What is the speed of sound in air at each temperature
: The coldest and hottest temperatures recorded are: 134 degrees Farhenheit and -80 degrees Farhenheit.
|
Journalize the entry to record the current depreciation
: Journalize the entry to record the current depreciation of the old equipment to the date of trade-in.
|