Measuring the performance of page replacement algorithms

Assignment Help Other Subject
Reference no: EM132462582

Project: Measuring the Performance of Page Replacement Algorithms on Real Traces.

In this project you are to evaluate how real applications respond to a variety of page replacement algorithms. For this, you are to write a memory simulator and evaluate memory performance using provided traces from real applications.

Memory Traces

You are provided with memory traces to use with your simulator. Each trace is a real recording of a running program, taken from the SPEC benchmarks. Real traces are big: billions and billions of memory accesses. However, a relatively small trace will be more than enough to keep you busy. Each trace only consists of one million memory accesses taken from the beginning of each program.

The traces are:
• gcc.trace
• swim.trace
• bzip.trace
• sixpack.trace

Each trace is a series of lines, each listing a hexadecimal memory address followed by R or W to indicate a read or a write. For example:

0041f7a0 R
13f5e2c0 R
05e78900 R
004758a0 R
31348900 W

Note, to scan in one memory access in this format, you can use fscanf() as in the following:
unsigned addr; char rw;
...
fscanf(file,"%x %c",&addr,&rw);

Simulator Requirements

Your job is to build a simulator that reads a memory trace and simulates the action of a virtual memory system with a single-level page table. Your simulator should keep track of what pages are loaded into memory. As it processes each memory event from the trace, it should check to see if the corresponding page is loaded. If not, it should choose a page to remove from memory. If the page to be replaced is "dirty" (that is, previous accesses to it included a Write access), it must be saved to disk. Finally, the new page is to be loaded into memory from disk, and the page table is updated. Assume that all pages and page frames are 4 KB (4096 bytes).

Of course, this is just a simulation of the page table, so you do not actually need to read and write data from disk. Just keep track of what pages are loaded. When a simulated disk read or write must occur, simply increment a counter to keep track of disk reads and writes, respectively.

Implement the following page replacement algorithms:
• RDM (randomly selects the page to replace)
• LRU
• FIFO
• VMS' second chance page replacement policy. You can find its description in the textbook (Chapter 23) and a more detailed description at the end of this document.

Structure and write your simulator in any reasonable manner. You may need additional data structures to keep track of which pages need to be replaced depending on the algorithm implementation. Think carefully about which data structures you are going to use and make a reasonable decision.

You need to follow strict requirements on the interface to your simulator so that we will be able to test and grade your work in an efficient manner. The simulator (called memsim) should take the following arguments:

memsim <tracefile> <nframes> <rdm|lru|fifo|vms> <debug|quiet>

The first argument gives the name of the memory trace file to use. The second argument gives the number of page frames in the simulated memory. The third argument gives the page replacement algorithm to use. The fourth argument may be "debug" or "quiet" (explained below.)

If the fourth argument is "quiet", then the simulator should run silently with no output until the very end, at which point it should print out a few simple statistics like this (follow the format as closely as possible):

total memory frames: 12 events in trace: 1002050 total disk reads: 1751 total disk writes: 932

If the fourth argument is "debug", then the simulator should print out messages displaying the details of each event in the trace. You may use any format for this output, it is simply there to help you debug and test your code.

Use separate functions for each algorithm, i.e.: your program must declare the following high level functions: rdm(), lru(), fifo() and vms().

Project Report

An important component of this project will be to write a report describing and evaluating your work and presenting your results using both tables and graphs (use Excel, Matlab, or another tool of your choice). You should think of this project as if it were a lab experiment in a physics or chemistry class. Your goal is to use the scientific method to learn as much as you can about the provided memory traces. For example, how much memory does each traced program actually need? What is the working set of each program? Which page replacement algorithm works best? Does one algorithm work best in all situations? If not, what situations favor what algorithms?

Your report should have the following parts:

Part 1. Introduction: A section that explains the essential problem of page replacement and briefly summarizes the structure and implementation of your simulator. Do not copy and paste text from this project description. In your own words, describe the overall structure and purpose of the experiment.

Part 2. Methods: A description of the experiments that you performed in order to learn something about each memory trace. Of course, it is impossible to run your simulator with all possible inputs, so you must think carefully about what measurements you need to answer the questions above. Make sure to run your simulator with an excess of memory, a shortage of memory, and memory sizes close to what each process actually needs. For instance, you may want to think strategically of what values you use for the <nframes> parameter. On one hand, you want to cover enough of the memory space to see when (a) your "process" does not have enough physical memory(thus, a lot of misses!), (b) when your process' working set fits in the memory, and (c) where increasing the allocated memory does not improve performance significantly. On the other hand, the more values for <nframes> you test with, the more hours you'll spend starring at the computer. To help you decide, think of number of frames as power of 2. So perhaps a sequence of 1, 2, 22, 23, 24, ..., 210 might be better than 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, for example. Also, think of what <nframes>x<frame size> means for today's processes -- perhaps an allocation of 2 TB of memory for a process is not particularly common these days (and neither is a physical memory of 32KB).

Part 3. Results: A description of the results obtained by running your experiments. Present the results using both tables and graphs that show the performance of each algorithm over a range of available memory. For instance, include a graph of hit rate vs. cache size for each algorithm. In the text, summarize what each graph or table shows and point out any interesting or unusual data points. Feel free to focus your report on one trace only. For that trace, give results and discuss in detail the performance of the 4 algorithms. Doing an outstanding job on simulating the addressing of memory on one trace only will give you full credit. If you have more time, identifying and comparing the sizes of the working sets of multiple traces might give you another point to discuss in the report.

Part 4. Conclusions: Describe what you have learned from the results. What have you learned about the memory traces? What have you learned about the paging algorithms? How does the size of available memory affect memory performance? Be sure to describe clearly how specific results above lead you to these conclusions.

The majority of your report grade will be drawn from the methods, results, and conclusions. Think carefully about how to run your simulator. Do not choose random input values. Instead, explore the space of memory sizes intelligently in order to learn as much as you can about the nature of each memory trace.

VMS

The VMS' second chance algorithm gets a very short treatment in the textbook, which may create confusion. Below is a bit more detailed explanation.

The VMS algorithm is best understood when two or more processes are competing for memory. For this reason and for simplicity, test your VMS implementation using only the gcc.trace input file with the following amendment: consider the addresses that start with 3 as being generated by one process, while all the other addresses are generated by a second process. This

way you can simulate (and we can grade a deterministic behavior of) memory references from two processes.

This is how the textbook describes the algorithm. The emphases are ours and mark important points for the implementation:

Segmented FIFO (from Three Easy Pieces, Arpaci-Dusseau & Arpaci-Dusseau)

To address these two problems, the developers came up with the segmented FIFO replacement policy [RL81]. The idea is simple: each process has a maximum number of pages it can keep in memory, known as its resident set size (RSS). Each of these pages is kept on a FIFO list; when a process exceeds its RSS, the "first-in" page is evicted. FIFO clearly does not need any support from the hardware, and is thus easy to implement.

Of course, pure FIFO does not perform particularly well, as we saw earlier. To improve FIFO's performance, VMS introduced two second-chance lists where pages are placed before getting evicted from memory, specifically a global clean-page free list and dirty-page list. When a process P exceeds its RSS, a page is removed from its per-process FIFO; if clean (not modified), it is placed on the end of the clean-page list; if dirty (modified), it is placed on the end of the dirty-page list.

If another process Q needs a free page, it takes the first free page off of the global clean list. However, if the original process P faults on that page before it is reclaimed, P reclaims it from the free (or dirty) list, thus avoiding a costly disk access. The bigger these global second-chance lists are, the closer the segmented FIFO algorithm performs to LRU [RL81].

Some hints and the pseudo-code interpretation of the algorithm described above are below:

• Parameters specific to VMS:
o RSS. You can consider it the same for the two processes and equal to nframes/2
o Number of processes: 2
• How to recognize which process requests a page: use gcc.trace. Consider addresses starting with 3 as being part of a process, all the others belonging to the other.
• For each process, a list of pages in memory is maintained in a FIFO order. The FIFO queues are of size RSS.
• In addition, the Clean and Dirty lists are maintained and are global. Assume Clean/Dirty are sufficiently large (The maximum space they need, we believe, is nframes/2+1 elements each). The Clean/Dirty lists work in FIFO order, although there are cases where elements are removed in a non-FIFO order. They contain the candidates for eviction, but if a page is in Dirty or Clean, it should still be in memory (possibly not for much longer).

new_page=get_page(address); //get VPN out of address
current_process = get_process(address); //figure out which process issued req if new_page in FIFO(current_process)
do nothing; //this means it is also in memory

else:

// maintain FIFO and Clean/Dirty buffers
page_out = insert new page into the FIFO of the current process; if (page_out) != NULL
if page_out is clean:
insert page_out into Clean;

else:
insert page_out into Dirty;

if new_page already in memory:
//it must be in Clean or Dirty, since it's in memory but it was
//not in FIFO when requested
remove new_page from Clean or Dirty, wherever it may be; //it may
//not be the first

else:
if there is room in memory, place it into any free frame; else:
frame_to_empty = first_out(Clean, Dirty); //remove first element from Clean, if any, or else from Dirty and return the frame number
place(new_page, frame_to_empty);

Attachment:- Measuring the Performance of Page Replacement.rar

Reference no: EM132462582

Questions Cloud

Discuss about professional certification and advanced degree : In 1,000-1,250 words, examine the importance of nursing education and discuss your overall educational goals. Discuss your options in the job market based on.
Describe elements and purpose of financial statement : Discuss components of financial ,Explain impact of accounting transactions in financial statements. Describe elements and purpose of each financial statement.
Discuss the elements of informed consent : Discuss the elements of informed consent and provide a clinical example about what can happen when some elements are not adhered to. The response must be typed.
How registered nurse can assist in protecting patient rights : Describe an organizational environment that would facilitate the ethical practice of nurses caring for chronically ill patients. As you read about patient.
Measuring the performance of page replacement algorithms : Evaluate how real applications respond to a variety of page replacement algorithms. For this, you are to write memory simulator and evaluate memory performance
Discuss areas of difficulty or new nursing interventions : Discuss two areas of difficulty you encountered or two new nursing interventions you learned this week at your clinical site as a Case Manager.
How is the company currently financed : How is the Company currently financed? This may be with common stock, preferred stock, bonds, leases, debt or any combination of them.
Define learning goals and objectives as a case manager : What are your upcoming week's specific learning goals and objectives as a Case Manager? What is your upcoming week's detailed schedule at your community.
Case study - mortgage approval time study : Case Study - Mortgage Approval Time Study,Determine the graphical display tool (e.g., Interaction Effects Chart, Scatter Chart, et cetera)

Reviews

Write a Review

Other Subject Questions & Answers

  Cross-cultural opportunities and conflicts in canada

Short Paper on Cross-cultural Opportunities and Conflicts in Canada.

  Sociology theory questions

Sociology are very fundamental in nature. Role strain and role constraint speak about the duties and responsibilities of the roles of people in society or in a group. A short theory about Darwin and Moths is also answered.

  A book review on unfaithful angels

This review will help the reader understand the social work profession through different concepts giving the glimpse of why the social work profession might have drifted away from its original purpose of serving the poor.

  Disorder paper: schizophrenia

Schizophrenia does not really have just one single cause. It is a possibility that this disorder could be inherited but not all doctors are sure.

  Individual assignment: two models handout and rubric

Individual Assignment : Two Models Handout and Rubric,    This paper will allow you to understand and evaluate two vastly different organizational models and to effectively communicate their differences.

  Developing strategic intent for toyota

The following report includes the description about the organization, its strategies, industry analysis in which it operates and its position in the industry.

  Gasoline powered passenger vehicles

In this study, we examine how gasoline price volatility and income of the consumers impacts consumer's demand for gasoline.

  An aspect of poverty in canada

Economics thesis undergrad 4th year paper to write. it should be about 22 pages in length, literature review, economic analysis and then data or cost benefit analysis.

  Ngn customer satisfaction qos indicator for 3g services

The paper aims to highlight the global trends in countries and regions where 3G has already been introduced and propose an implementation plan to the telecom operators of developing countries.

  Prepare a power point presentation

Prepare the power point presentation for the case: Santa Fe Independent School District

  Information literacy is important in this environment

Information literacy is critically important in this contemporary environment

  Associative property of multiplication

Write a definition for associative property of multiplication.

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