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

  Plan the logic for a program for the sales manger

plan the logic for a program for the sales manger of the couch potato furniture company. The manger needs a program to determine the profit on any item sold. Input includes the wholesale price and retail price for an item.

  Describe any generalization/specialization relationships

Describe any generalization/specialization relationships

  Why should a company implement a csr program

3. How does the CSR program apply to today's trends and current issues in the global marketplace? 4. Whom is the company responsible to? 5. Why should a company implement a CSR program?

  Write a menu-driven program to manage a membership

Write a menu-driven program to manage a membership list. Assume that the names and phone numbers of all members are stored in alphabetical order (by last name and then by first name) in the text file MemberPhones.txt

  Explain the current business rules for drive-n-drop

Create an ERD for each of the following statements that describe the current business rules for Drive-n-Drop. For each new statement being the business rule, extend the ERD to include the additional business rule in the ERD

  What is the difference between a hacker and a cracker

Should employees have the right to the expectation of privacy while using an employer's computer workstation? Why or why not? How far should an employer be able to take their investigation of off-work but online habits of employees? Should off..

  How verbal and nonverbal communication affect communication

Write 1,750- to 2,100-word paper explaining how verbal and nonverbal communication can affect communication in given areas: Police situations (public announcement to the press).

  Review an article from teradata student network

You are required to review an article from Teradata Student Network or a refereed journal that is relevant to concepts discussed in any ONE (1) of the chapters under review. You must integrate in the last paragraph of this report, how the findings fr..

  More efficient way to create a midiheap

How can you code for a more efficient way to create a midiheap?

  What is the simplest form of the boolean function

What is the simplest form of the Boolean function y′ . (x + y)?

  When you need to return the value of a function

In C programming: When you need to return the value of a function and you are not allowed to use the normal return value of the function, could you do it using: Call_by_val or Call_by_reference?

  News website for australian broadcasting corporation

Provide an expert review of the news website for Australian Broadcasting Corporation

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