Ask Programming Language Expert

Part 1: Adding a new system call
Implement a new system call:

int sys_pgfltstats(pid_t pid, int flag, pf_info_struct *info)

The pf_info_struct should contain fields for:

1. total number of minor page faults
2. total number of major page faults
3. number of processes included in these counts 

If pid is:

* -1: then return total count statistics for all processes in the system.
* positive then look at the flag field and do the following:
1. flag is PGFLTSTAT_PROC: then return count statistics for the single process with the matching pid
2. flag is PGFLTSTAT_OWNER: then return the total count statistics for all process in the system with the same owner as the specified pid. 

You can use fields in task_struct for obtaining these, or you could use (or add) values to the fault handling part of the kernel for obtaining them. Make sure to check for error conditions and return appropriate error values as in the previous assignments. Remember that header file contents (prototypes and definitions) that should only be visible inside the kernel (not at user level) should be inside #ifdef __KERNEL, and #endif preprocessor directives.

You can grab my starting point code for lab2 to use as a starting point for your system call implementation (~newhall/public/cs45/lab2/).

You can use vmstat, and /proc/pid/ files to help you determine if your system call is implemented correctly (look at vmstat and proc (man 5 proc) man pages for more info).

Kernel code you may want to read:

* page fault handling routines in do_page_fault() in arch/i386/mm/fault.c and mm/memory.c
* page replacement code in vmscan.c, which begins with try_to_free_pages. 

Part 2: Experiments Testing the VM system and a Written Report

For this part, you will use your system call (and other utilities) to collect information about page faults and other performance data for different programming loads. I want you to (through experiments) determine what page replacement algorithm Linux likely implements. I'm sure you can figure out what Linux's page replacement policy is just by reading Linux documentation and/or reading Linux source code. However, the point of this assignment is to see if you can verify experimentally what you know (or suspect) about Linux's page replacement policy.

Think about running experiments to answer the questions about how the policy works for different types of workloads, and what that tells you about the policy. In designing your experiments, you should write user-level test programs that access memory in different patterns, and run different experiments using them to collect performance data to help you answer questions like:

1. When does Linux's page replacement policy work well (what types of workloads)?
2. When does it not work well?
3. How well does it work for a mixed workload?
4. etc. 

And what do the answers to these questions tell you about Linux's page replacement policy? For example try and answer questions like: is it most like FIFO? or MRU? LRU? or Working Set? etc. Why or why not? In what way(s)?

To get started, you will likely want to read kernel code and other Linux documentation to help you develop some initial hypotheses. You can test negative hypotheses as well as positive ones (i.e. "I don't think Linix implements the X policy, and I'm going to test this by ..."), but you should have some positive hypotheses as well; there is a difference between negative hypotheses that can help support your positive ones, and bad hypotheses (and bad experiments) that don't really show anything.

Next,think about how to design experiments to test your hypotheses:

* You will want to write some user-level test programs that allocate memory and access it repeatedly in some pattern (you need to allocate enough memory to cause page faults).
* Use these test programs to design and run experiments to help support (or refute) your hypotheses. 

Look at the details in the Report section below to help guide your hypothesis and experiments design and testing.

To write test programs that use enough memory to trigger paging, look at the /proc/meminfo file. This give the total amount of free memory (MemFree, in Kbytes). If you are running an experiments, make sure the the process(es) allocate enough memory to trigger page replacement (they need to allocate enough virtual memory space so that it won't all fit into free physical memory). However, be careful that you do not allocate too much memory, otherwise, you can run out of swap space and the kernel will start killing process. The amount of free swap space can be found in /proc/meminfo (SwapFree, in Kbytes).
Report
You should write 3-5 page report (do not give me anything longer than 5 pages) describing your experiments and results.

In particular, your report should have the following:

1. Introduction. Describe at a high-level what you are doing and why, and describe what your high-level hypothesis is (i.e. "We started out guessing that Linux's page replacement policy is X, but our experiments will show that it is in fact, more like Y" or "we start out making no assumptions about Linux's page replacement policy, and our experiments will answer the question of is it more like X, Y or Z.").

2. Short paragraph describing how you implemented your system call to get get per-process, per-owner, and system wide page fault counts? Also, describe other Unix utilities you used to collect performance data for your experiments.

3. Main part: describe your experiments and results: For each experiment, you should:
1. Clearly state what your hypothesis is
(i.e. "Application that does X should be a bad/good case for Linux's page replacement policy because ...)
2. Explain how your experiment is testing that hypothesis
(We are testing this hypothesis by running the application N times on and collecting X,Y, and Z metrics using our system call, vmstat, time,... With these measures, we can see whether or not ...).
3. Present your Results.
4. Explain your results!
(Our results show that ... This does/does not match our expected result, because ... (if it doesn't, think about some other tests you could run to explain why it doesn't, or look for data you do have to explain it) 
Quality of Experiments is much, much better than quantity; a few well thought out and well done experiments is sufficient.

4. Conclusion. It should include a statement of the major result(s) of your experiments (which policy(ies) is Linux's most like? and in what way(s)?). Also, tell me what you found to be the most difficult part of the hypothesis testing phase of this assignment.

Programming Language, Programming

  • Category:- Programming Language
  • Reference No.:- M9649554

Have any Question?


Related Questions in Programming Language

Assignment - haskell program for regular expression

Assignment - Haskell Program for Regular Expression Matching Your assignment is to modify the slowgrep.hs Haskell program presented in class and the online notes, according to the instructions below. You may carry out th ...

Assignment task -q1 a the fibonacci numbers are the numbers

Assignment Task - Q1. (a) The Fibonacci numbers are the numbers in the following integer sequence, called the Fibonacci sequence, and are characterised by the fact that every number after the first two is the sum of the ...

Question - create a microsoft word macro using vba visual

Question - Create a Microsoft Word macro using VBA (Visual Basic for Applications). Name the macro "highlight." The macro should highlight every third line of text in a document. (Imagine creating highlighting that will ...

Assignmentquestion onegiving the following code snippet

Assignment Question One Giving the following code snippet. What kind of errors you will get and how can you correct it. A. public class HelloJava { public static void main(String args[]) { int x=10; int y=2; System.out.p ...

Assignment - proposal literature review research method1

Assignment - Proposal, Literature Review, Research Method 1. Abstract - Summary of the knowledge gap: problems of the existing research - Aim of the research, summary of what this project is to achieve - Summary of the a ...

1 write a function named check that has three parameters

1. Write a function named check () that has three parameters. The first parameter should accept an integer number, andthe second and third parameters should accept a double-precision number. The function body should just ...

Assignment - horse race meetingthe assignment will assess

Assignment - Horse Race Meeting The Assignment will assess competencies for ICTPRG524 Develop high level object-oriented class specifications. Summary The assignment is to design the classes that are necessary for the ad ...

Task silly name testeroverviewcontrol flow allows us to

Task: Silly Name Tester Overview Control flow allows us to alter the order in which our programs execute. Building on our knowledge of variables, we can now use control flow to create programs that perform more than just ...

Structs and enumsoverviewin this task you will create a

Structs and Enums Overview In this task you will create a knight database to help Camelot keep track of all of their knights. Instructions Lets get started. 1. What the topic 5 videos, these will guide you through buildi ...

Task working with arraysoverviewin this task you will

Task: Working with Arrays Overview In this task you will create a simple program which will create and work with an array of strings. This array will then be populated with values, printed out to the console, and then, w ...

  • 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