Analyze how the number of page faults depends on page size

Assignment Help Operating System
Reference no: EM131965297

Operating Systems Assignment

In this lab you will simulate demand paging and see how the number of page faults depends on page size, program size, replacement algorithm, and job mix (job mix is defined below and includes locality and multiprogramming level).

The idea is to have a driver generate memory references and then have a demand paging simulator (called pager below) decide if each reference causes a page fault. Assume all memory references are for entities of one fixed size, i.e., model a word oriented machine, containing M words. Although in a real OS memory is needed for page tables, OS code, etc., you should assume all M words are available for page frames.

The program is invoked with 6 command line arguments, 5 positive integers and one string M, the machine size in words.

P, the page size in words.

S, the size of each process, i.e., the references are to virtual addresses 0..S-1. J, the ‘‘job mix'', which determines A, B, and C, as described below.

N, the number of references for each process.

R, the replacement algorithm, FIFO, RANDOM, or LRU.

The driver reads all input, simulates N memory references per program, and produces all output. The driver uses round robin scheduling with quantum q=3 (i.e., 3 references for process 1, then 3 for process 2, etc.).

The driver models locality by ensuring that a fraction A of the references are to the address one higher than the cur- rent (representing a sequential memory reference), a fraction B are to a nearby lower address (representing a back- ward branch), a fraction C are to a nearby higher address (representing a jump around a ‘‘then'' or ‘‘else'' block), and the remaining fraction (1-A-B-C) are to random addresses. Specifically, if the current word referenced by a process is w, then the next reference by this process is to the word with address

• w+1 mod S with probability A
• w-5 mod S with probability B
• w+4 mod S with probability C
• a random value in 0..S-1 each with probability (1-A-B-C)/S

Since there are S possible references in case 4 each with probability (1-A-B-C)/S, the total probability of case 4 is 1-A-B-C, and the total probability for all four cases is A+B+C+(1-A-B-C)=1 as required.

There are four possible sets of processes (i.e., values for J)

J=1: One process with A=1 and B=C=0, the simplest (fully sequential) case. J=2: Four processes, each with A=1 and B=C=0.

J=3: Four processes, each with A=B=C=0 (fully random references).

J=4: One process with A=.75, B=.25 and C=0; one process with A=.75, B=0, and C=.25; one process with A=.75, B=.125 and C=.125; and one process with A=.5, B=.125 and C=.125.

The pager routine processes each reference and determines if a fault occurs, in which case it makes this page resi- dent. If there are no free frames for this faulting page, a resident page is evicted using replacement algorithm R. The algorithms are global (i.e., the victim can be any frame not just ones used by the faulting process). Because the lab only simulates demand paging and does not simulate the running of actual processs, I believe you will find it eas- iest to just implement a frame table (see next paragraph) and not page tables. My program is written that way. (This is advice not a requirement.)

As we know, each process has an associated page table, which contains in its ith entry the number of the frame con- taining this process's ith page (or an indication that the page is not resident). The frame table (there is only one for the entire system) contains the reverse mapping: The ith entry in the frame table specifies the page contained in the ith frame (or an indication that the frame is empty). Specifically the ith entry contains the pair (P, p) if page p of process P is contained in frame i.

The system begins with all frames empty, i.e. no pages loaded. So the first reference for each process will definitely be a page fault. If a run has D processes (J=1 has D=1, the others have D=4), then process k (1<=k<=D) begins by referencing word 111*k mod S.

Your program echos the input values read and produces the following output. For each process, print the number of page faults and the average residency time. The latter is defined as the time (measured in memory references) that the page was evicted minus the time it was loaded. So at eviction calculate the current page's residency time and add it to a running sum. (Pages never evicted do not contribute to this sum.) The average is this sum divided by the number of evictions. Finally, print the total number of faults and the overall average residency time (the total of the running sums divided by the total number of evictions).

Use the same file of random numbers as in lab2. Good luck.

Notes:

(1) Despite what some books may say, the % operator in C, C++, and Java is the remainder function not the mod function. For most (perhaps all) C/C++/Java compilers, (-2)%9 is -2; whereas (-2) mod 9 = 7. So to calculate (w-5) mod S above, write (w-5+S)%S.

(2) The big issue in this lab is the REplacement of pages. But the placement question does arise early in the run when there are multiple free frames. It is important that we all choose the same free frame so that you can get the benefit of my answers and debugging output and so that on the mailing list everyone will be referring to the same situation. I choose the highest numbered free frame; you must do so as well

(3) Since random numbers are involved, we must choose the random numbers in the same order. Here is a non- obvious example. In the beginning of your program you set the referenced word for each job to be 111*k as described in the lab. Now you want to simulate q (quantum) references for each job. I suggest and used code like the following.

for (int ref=0; ref<q; ref++) {

simulate this reference for this process calculate the next reference for this process

}

One effect is that after simulating the qth reference you will calculate the first reference for the next quan- tum. Hence, you may be reading the random number file before you switch to the next process. Specifi- cally, at the beginning of the run you have the first reference given to you for process 1, namely 111*1=111 mod S. Now you simulate q references (the first to address 111 mod S) and you calculate the next q addresses. These calculations use one or two random numbers for each reference (two if a random reference occurs). So you read the random number file once or twice for the last reference (q+1), even though you will be context switching before simulating this reference. Although you do not have to use my code above, you do need to use the random numbers the same way I do.

(4) When calculating the next word to reference, you have four cases with probability A, B, C, and 1-A-B-C. Read a random number from the file and divide it by RAND_MAX+1=2147483648 (RAND_MAX is the largest value returned by the random number generator I used to produce the file; it happens to equal Inte- ger.MAX_VALUE). This gives a quotient y satisfying 0?y<1. If the random number was called r (an inte- ger) the statement you want in Java is (note the 1d)

double y = r / (Integer.MAX_VALUE + 1d) The C/C++ equivalent is (note the 1.0)

double y = r / (MAXINT + 1.0)

If y<A, do case 1 (it will occur with probability A),

else if y<A+B, do case 2, (it will occur with probability B), else if y<A+B+C, do case 3 (it will occur with probability C).

else /* y>=A+B+C */, do case 4 (it will occur with probability 1-A-B-C.)

The above is a handy technique you may find useful outside this class so I recommend you figure out why it works. This is definitely not a hint that I will put it on the final exam. I won't.

Attachment:- Inputs-and-Outputs.rar

Reference no: EM131965297

Questions Cloud

What is the growth rate for dalton inc : Dalton Inc. has a return on equity of 10.9 percent and retains 545 percent of its earnings for reinvestment purposes. It recently paid a dividend of $3.25.
What is the effective annual rate? of the mortgage : What is the effective annual rate? (EAR) of the mortgage at 11.25 APR with quarterly ?payments?
Aspect of organizing in the context of organizational : Identify and explain the four fundamental issues that pertain to the formal aspect of organizing in the context of organizational structures.
Why this company would be a good or bad employment choice : In a memo report to your instructor, summarize your research findings. explain why this company would be a good or bad employment choice.
Analyze how the number of page faults depends on page size : Simulate demand paging and see how the number of page faults depends on page size, program size, replacement algorithm, and job mix.
What surprised you most about what was covered documentary : Take one of those groups (not the U.S.) and explain how and why they remember the War of 1812, if they remember it at all.
Find the yield to maturity on the bonds : Dan is considering the purchase of Super Technology, Inc. bonds that were issued 6 years ago. When the bonds were originally sold they had a 21-year maturity.
What is the default risk premium on the corporate bonds : A company’s 5-year bonds are yielding 7.75% per year. what is the default risk premium on the corporate bonds?
What is the taxable income for simmons : Daniel Simmons arrived at the following tax information: Gross salary $ 54,250 Interest earnings $ 75 Dividend income $ 140 One personal exemption $ 3,950.

Reviews

Write a Review

Operating System Questions & Answers

  Which mobile phone vendor would you choose

After your research, which mobile phone vendor would you choose? Why? Is this the vendor you are currently using for your personal mobile phone

  Word processing software application

Boardman Management Group manages Baderman Island resort. They are planning whether to upgrade the word processing software or to buy a new word processing software application.

  Multitasking scheduling schemas

Think about a particular system that does not have an interrupting clock. The only way a procedure can lose the processor is to voluntarily surrender it.

  Operating system forensics

Compare and contrast the forensic processes when dealing with Windows-based, Linux-based, and Macintosh-based systems. Explain the challenges of each of these operating systems in regard to system forensics and determine which of these you conside..

  Given a short-term scheduling algorithm

Explain why this algorithm favors I/O bound programs and yet does not permanently deny processor time to processor bound programs.

  Question about about telecommunications

Think about a simple telephone network consisting of two end offices and one intermediate switch with a 1-MHz full-duplex trunk in each end office and the intermediate switch.

  Does the method work if there is a single cpu switches

Does this method work if There is a single CPU that switches between processes every 100 msec and Two CPUs share a common memory in which the semaphore is located?

  Difference between a policy and a procedure

Write a 500+ word paper that answers and fully discusses the topic questions. What is the difference between a policy and a procedure?

  Identify various hardware components and network topologies

Describe protocols at the different layers of the OSI model and explain their functionality

  Define what is meant by power efficiency

Order the following modulation types in terms of spectral efficiency (best to worse) and explain why (be specific, show a number and how you got it): 64-QAM, QPSK, 8-PSK, and BPSK. Assume that the r=0, perfect filtering.

  Write a program to simulate the scheduling of cpu

Write a program to simulate the scheduling of CPU. The program will randomly generate process CPU burst based on user's setting.

  What is meant by user time in terms of cpu usage

What is the size of the cache on your CPU? What is meant by "User Time" in terms of CPU usage? What is meant by "Kernel" or "System" time in terms of CPU usage?

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