Regions and memory management

Assignment Help Basic Computer Science
Reference no: EM13963456

Regions and Memory Management

There are a wide variety of algorithms to chose from when implementing garbage collection for a speci?c language. In this problem, we examine one algorithm for ?nding garbage in pure Lisp (Lisp without side effects) based on the concept of regions. Generally speaking, a region is a section of the program text. To make things simple, we consider each function as a separate region. Region-based collection reclaims garbage each time program execution leaves a region. Because we are treating functions as regions in this problems, our version of region-based collection will try to ?nd garbage each time a program returns from a function call.

(a) Here is a simple idea for region-based garbage collection:

When a function exits, free all the memory that was allocated during execu- tion of the function.

However, this is not correct as some memory locations that are freed may still be accessible to the program. Explain the ?aw by describing a program that could possibly access a previously freed piece of memory. You do not need to write more than four or ?ve sentences; just explain the aspects of an example program that are relevant to the   question.

(b) Fix the method in part (a) to work correctly. It is not necessary for your method to ?nd all garbage, but the locations that are freed should really be garbage. Your answer should be in the following form:

When a function exits, free all memory allocated by the function except....

Justify your answer. (Hint: Your statement should not be more than a sentence or two. Your justi?cation should be a short paragraph.)

(c) Now assume that you have an correctly functioning region-based garbage col- lector. Does your region-based collector have any advantages or disadvantages over a simple mark-and-sweep collector?

(d) Could a region-based collector like the one described in this problem work for impure Lisp? If you think the problem is more complicated for impure Lisp, brie?y explain why. You may consider the problem for C instead of for impure Lisp if you like, but do not give an answer that depends on speci?c properties of C such as pointer arithmetic. The point of this question is to ex- plore the relationship between side effects and a simple form of region-based collection.

Reference no: EM13963456

Questions Cloud

How many photons are incident on surface breast tissue : The entrance exposure during a mammography examination is 100mR. Suppose the photon bean consists of photons each of energy 20 keV. How many photons are incident on a 1 cm^2 surface of breast tissue?
What is the average molar specific heat in this range : The molar specific heat of many materials at low temperatures is found to obey the Debye law C_v = A[T/theta]^3 where A is a constant equal to 1.94 x 10^3 Jmol^-1K^-1 and with the Debye temperature theta taking different values for different mater..
Selling an old a car : John called you late on Friday afternoon with a simple question. He is considering selling an old a car and wants to know what the tax implications will be.
Richard is an employee of the dun construction corp : Richard is an employee of the Dun Construction Corp. While delivering materials to a con- struction site, he carelessly backs Dun's truck into a pas- senger vehicle driven by Green. This is Richard's second accident in six months. When the company ow..
Regions and memory management : There are a wide variety of algorithms to chose from when implementing garbage collection for a speci?c language. In this problem, we examine one algorithm for ?nding garbage in pure Lisp (Lisp without side effects) based on the concept of regions..
Find the frequency at which photon density is a maximum : In lecture we derived a distribution, uf(f)df, for the energy density in cavity radiation as a flurction of frequency. If hf is the energy of a photon, modify this distribution to find a distribution nfdf of photon density as a function of frequenc..
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

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Having staff with the proper skill sets is immensely

Having staff with the proper skill sets is immensely important to accomplishing corporate objectives. List and support three best practices in staffing future organizational needs.

  Define why study computer ethics

Why study computer ethics? 2 revis & teaching . compare/contrast which do you agree, Whistle blowing problems assocuated with it teaching effects practic how has

  Explaining multiple client computers and servers

In network with multiple client computers, servers, switches and wireless access points, write down resources must be scanned for possible vulnerabilities.

  Takes a string as input and returns a string

Write a method that takes a String as input and returns a String containing the middle character of the String if the length of that String is odd.

  The many challenges of working in it

What Bryan found on an executive's computer six years ago still weighs heavily on his mind. He's particularly troubled that the man he discovered using a company PC to view pornography of Asian women and of children was subsequently promoted and m..

  Benefit from implementing locking methods

Describe how locks could be used in order to qualify data transactions and enhance concurrency control. Suggest at least two business scenarios that would benefit from implementing locking methods.

  Briefly describe how you could achieve this

Suppose you would like to have most of your program variables residing in external RAM while a few time-critical variables should reside in the first 128 bytes of internal RAM. Briefly describe how you could achieve this.

  Create 3 files date.h, date.cpp, date_main.cpp

create 3 files date.h, date.cpp, date_main.cpp that will create a birth date and a graduation date in the form MM/DD/YYYY

  Research options for improving the current use of tcp/ip

Research options for improving the current use of TCP/IP and recommend new software and equipment that's available. Describe how use of equipment, software, and multiplexing could aid in improving use for communications which would reduce network con..

  Compare and contrast the differences between unix

Compare and contrast the differences between Unix (or Linux) and Window Traceroute.  All the codes for each ICMP error message are not fully listed and explained.  Identify a few scenarios in which ICMP error messages are generated?What available too..

  Creation of a base geometric class

The lab will require the creation of a base geometric class, called Shape, and two sub classes, Circle and Rectangle, that are derived public from the class Shape.

  Data execution protection

Data Execution Protection (DEP)

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