# Building Abstractions with Procedures Section 2 - Part 1

## Section 1.2 Procedures and the Processes They Generate

Exercises in this section of SCIP.

Exercise 1.9. Each of the following two procedures defines a method for adding two positive integers in terms of the procedures inc, which increments its argument by 1, and dec, which decrements its argument by 1.

# Building Abstractions with Procedures Section 1

## Section 1.1 The Elements of Programing

Exercises in this section of SICP.

Exercise 1.1. Below is a sequence of expressions. What is the result printed by the interpreter in response to each expression? Assume that the sequence is to be evaluated in the order in which it is presented.

# LRU-based Replacement Algorithms Application of Flash Memory

## Abstract

Nowadays, NAND flash memory has been widely used as storage medium for embedded systems because of its small size, lightweight, shock resistance, power economic and high reliability. As its capacity increases and its price decreases, flash-memory-based SSDs (abbreviated Solid-state Driver) has also become an alternative of magnetic disk in enterprise computing environment. In addition, flash memory has the characteristics of not-in-place update and asymmetric I/O costs among read, write, and erase operations, in which the cost of write/erase operations is much higher than that of read operation. Hence, the buffer replacement algorithms in flash-based systems should take the asymmetric I/O costs into account. There are several solutions to this issue, such as LRU, CFLRU, APRA and AML. As we LRU policy is a basic cache replacement algorithm and page replacement algorithm. Thus we try to introduce the different variants algorithm of LRU used especially in flash memory.

# Spring IoC Container Part 3

## DefaultSingletonBeanRegistry

Last time we find that in the DefaultListableBeanFactory it provides map to save bean definitions. But when getting bean instance, we need to step into DefaultSingletonBeanRegistry. First let’s see the document:

Generic registry for shared bean instances, implementing the SingletonBeanRegistry. Allows for registering singleton instances that should be shared for all callers of the registry, to be obtained via bean name.

Also supports registration of DisposableBean instances, (which might or might not correspond to registered singletons), to be destroyed on shutdown of the registry. Dependencies between beans can be registered to enforce an appropriate shutdown order.

This class mainly serves as base class for BeanFactory implementations, factoring out the common management of singleton bean instances. Note that the ConfigurableBeanFactory interface extends the SingletonBeanRegistry interface.

Note that this class assumes neither a bean definition concept nor a specific creation process for bean instances, in contrast to AbstractBeanFactory and DefaultListableBeanFactory (which inherit from it). Can alternatively also be used as a nested helper to delegate to.

# Spring IoC Container Part 2

## Log4J

When using Spring framework, we must use Apache Common Logging to print log in console or binary files. As we known, Spring log configuration can change in the web.xml when it works on server. But in these series of articles, we try to analyze the Spring core techniques without works on server. So there should have another way to configure log without web.xml because we want to see the debug informations.

Spring gives Log4jConfigurer.initLogging() method (has been deprecated in Spring 4.2.1) to initialize log4j from the given file location. Note that we always use Maven to build project, but maven might mash src and resources folders to one. Thus we should use classpath: ,without slash, to represent resources folder in the project.

Now Apache Commons Logging (JCL) provides thin-wrapper Log implementations for other logging tools, including Log4J. But Log4jConfigurer.initLogging() calls methods from log4j 1.x. It means that we should add log4j 1.x dependency to make sure that our log configuration file works smoothly.