Problem regarding the reference counting

Assignment Help Basic Computer Science
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 and a value 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.

Reference no: EM13963450

Questions Cloud

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.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Review methodologies for design & development

Investigate the requirements for the system and produce a Requirements Specification. Review methodologies for design & development and select the most appropriate

  What is meant by the monetary approach to exchange

What is meant by the monetary approach to exchange-rate determination? What are its major predictions concerning exchange-rate movements? Give examples.

  Write a program that calculates a savings accounts yearly

Write a program that calculates a savings accounts yearly savings amount. The savings account pays an interest rate of 3% yearly.

  Create a fully unbalanced bst

I need to create a program written in Java. It needs to create a fully unbalanced BST. It must have 26 levels. It must demonstrate the insertion of elements into the BST.

  Identify differences and similarities of the business models

What are they offering to their buyers or consumers via the Web (e.g., product, service, information, recreation)?

  How much does the disk slow down the cpu

The CPU normally fetches and executes one 32-bit in- struction every 1 nsec. How much does the disk slow down the CPU?

  A paper three to four pages covers data warehouse

Subject background: Data Modeling. Need a paper three to four pages covers data warehouse - a subject-oriented, integrate, time-variant, and nonvolatile set of data that supports decision making. Within the paper an explanation of subject, int..

  Logical structure of active directory

How would you design the logical structure of Active Directory for the Rough Country Miles of Alaska, and what domain naming structure would you suggest?

  Find the inverse of a and call it matrix x

Define the matrices: A = [12 16 4;23 1 21;9 10 1] and B = [2 7 14;3 11 2;-9 10 12]. Perform matrix multiplication AB. Perform matrix multiplication BA. Are the answers from Parts (a) and (b) the same? If yes, explain why. If not, explain why. Find th..

  Advantages and disadvantages of dbms-provided security

Describe the advantages and disadvantages of DBMS-provided security

  Fraction with a denominator

Simplify each of the following algebraic expressions. All sets are assumed to be subsets of a universal set U.

  Risks associated with directly executing user input

What are the risks associated with directly executing user input? What are the minimum steps needed to parse user input before it is allowed to be used in execution?What are the risks associated with inheritance in classes? Why are generic classes bo..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd