Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

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.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M91631470

Have any Question?


Related Questions in Computer Engineering

Question suppose you are the analyst charged with

Question : Suppose you are the analyst charged with developing a new system to help senior managers make better strategic decisions. What methodology would you use? How would the business strategy affect your approach? W ...

For this assignment you will produce a reflection paper

For this assignment, you will produce a reflection paper based on your experience in the BSIT program, and in preparation for developing a professional portfolio starting next week. The purpose of the reflection paper is ...

Explain a business process you are familiar with describe

Explain a business process you are familiar with. Describe how a computer-based information system is related (or used) in this business process. Explain how a computer-based information systems can improve the efficienc ...

Question a security system is used to monitor doors and

Question : A security system is used to monitor doors and windows of a residence. This system uses several components, including photodiodes and contact switches to detect intruders. Circuits associated with contact swit ...

Questions 1 what are the four parts of the administrative

Questions: 1. What are the four parts of the administrative simplification requirements of HIPAA? 2. Name three factors used to determine whether you need to comply with HIPAA. 3. What are the three categories of entitie ...

Jeff decides to start saving some money from this upcoming

Jeff decides to start saving some money from this upcoming month onwards. He decides to save only $500 at first, but each month he will increase the amount invested by $100. He will do it for 60 months (including the fir ...

Question based upon your company profile install and

Question: Based upon your company profile, install and configure Windows Server within the virtual environment. 1. Ensure that the server name is appropriate for your corporation. 2. Create a complex password for the Adm ...

On the spot courier services grew and changed over the

On the Spot courier services grew and changed over the years. At first, Bill received requests for package pickups on his mobile phone, recorded that information in a log, and would then drive around to retrieve all the ...

Suppose a program has a button with the caption quit

Suppose a program has a button with the caption "Quit" Suppose also that Name property of this button is btnQuit. Write a btnQuit_Click event precede that gives the user a second chance before ending the program. The prt ...

Scenario 1 19500 ascii characters are transmitted over a 3

Scenario 1: 19,500 ASCII characters are transmitted over a 3 Mbps circuit. The protocol uses 8-bits to encode each ASCII character, and adds an additional parity bit to help detect errors. Calculate the transmission effi ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As