-
Page replacement algorithm
I have a problem to code a page replacement algorithm simulation in VB.net, I have the random numbers that represent the pages that will be used, and I have been able to put the first pages in to 'memory'. I try to program First-in/first out, Least recently used and optimal, but I have no idea how to do it. Can someone please help me?
See more here: http://en.wikipedia.org/wiki/Page_re...ent_algorithms
.NET 2.0
-
Re: Page replacement algorithm
Multics to the rescue:
http://www.multicians.org/an61.html#sXVII
Then search for:
Main Memory Replacement Algorithm
or
http://www.multicians.org/multics-vm.html
and search for
8.4 The Page Fault Handler
-
Re: Page replacement algorithm
Thank you, but sorry, that was not what I was looking for.
I am going to write a simulation in Visual BASIC .net.
I do understand how the algorithms works, I only have troubles writing them.
-
Re: Page replacement algorithm
Mostly what you will find here are people willing to help you with YOUR code. That means you have to put something together and ask for help.
To get started create an array to simulate memory. If you create it with multi-dimensions you can use the extra dimensions as your page table descr.
dim VirtMem(10000,3) say
A Timer will be useful to make Random hits into our virtual memory.
BTW - What version of Basic are you using?
-
Re: Page replacement algorithm
I have put something together, and I have tried for days to continue with the code!
I have the first pages from memory in a one dimensional array right now.
can it also be a good idea to use array(o), array(2) etc. to page numbers, and array(1), array(3) etc. for page table descr.?
-
Re: Page replacement algorithm
version of basic
I can help with 2005 or 2008
-
Re: Page replacement algorithm
.NET 2
ASP.net 2
I don't use Visual Studio
-
Re: Page replacement algorithm
-
Re: Page replacement algorithm
I don't use an IDE. I write in notepad and similar.
-
Re: Page replacement algorithm
Why would anyone not take advantage of the capabilities of Visual Studio. This is regression at best. Notepad cannot replace intellisense, object Browser, and the various features that make VB such a great environment. VB Express is availalbe for free so why use notepad?
-
Re: Page replacement algorithm
I don't know. Anyway, in such a small program will it really help much?
Maybe I will try it.
-
Re: Page replacement algorithm
The more power to you if you can do it. Good luck :)
-
Re: Page replacement algorithm
Download Visual Basic Express 2008 - it is free.
I am done writing it, and it works as expected, even thrashes when I disable the write of dirty pages.
-
Re: Page replacement algorithm
I don't have my PC with Windows right now, so I can't download it now.
and can you please show me the code?;)
-
Re: Page replacement algorithm
Sure. I should get at least a notation in your project, K.
-
Re: Page replacement algorithm
Thank you very much!
but I don't know exactly how to compile it (my command line compiler gives me errors) I was thinking to put it in an ASP.net page, any suggestion? Do I have to install Visual Studio to make it work (I am using my PC with Windows now, so I can)
-
Re: Page replacement algorithm
You mean the PC you don't have.
Download Visual Basic Express 2008.
-
Re: Page replacement algorithm
I have it available now, I did not earlier today (I got it back earlier than expected). I am downloading now.
-
Re: Page replacement algorithm
I'll zip and post the whole project.
-
Re: Page replacement algorithm
Thank you, but it's all too much. I was not looking for something that showed output while simulating. Just some simple algorithms I could put in a ASP.net page or a console window. To count page faults. And as already mentioned, I have a set of random numbers that represent the pages that the 'processes' will need.
The memory size is stored in a variable (from user input)
-
Re: Page replacement algorithm
I am about done with an update that corrects some of the flaws in the original, and more closely emulates the write to backing store. I will post a reply here with a link to the new attachment.
Sorry you do not feel that it meets your needs. It certainly looks like a Virtual Memory System with a LRU Page Replacement Algorithm.
-
Re: Page replacement algorithm
Has hooks for simulating programs causing faults. Currently the faulting program is generated randomly.
-
Re: Page replacement algorithm
Thank you very much.
One more question: how do I work with empty arrays without getting errors? (System.NullReferenceException)
I am translating a program from PHP.
-
Re: Page replacement algorithm
why are you working with empty arrays? specific code, specific answers.
-
Re: Page replacement algorithm
An array should be copied with references to itself, the array can be set in different places in the code.
Simple example:
Code:
<%
Dim b%, d%, g%
b=2
d=1
g=2
dim a()
DIM c(,)
WHILE g < 10
if a(b) = c(b, d)
c(b, d)=c(b -1, d)
Else
c(b, d)=g
END if
g = g + 1
END WHILE
%>
-
Re: Page replacement algorithm
You should get System.NullReferenceException in the example.
Code:
dim a () 'create an empty array
b=1
a(b) = 2 'System.NullReferenceException should happen
-
Re: Page replacement algorithm
Exactly!
how do I avoid that? a similar program in PHP will work. what is the simplest way to avoid it? it looks like On error GoTo would not work here ( anyway it would have been difficult to know where to place the label because the PHP script is full of such things. :(
-
Re: Page replacement algorithm
I am curious about your original problem statement:
"I have the random numbers that represent the pages that will be used"
It occurs to me that there must be more information about the simulation system, like
How much physical memory does it have
Are the pages the ones causing a page fault
What is the arrival rate
etc.
-
Re: Page replacement algorithm
That is not a problem anymore, I guess your help was enough for that. But I also use a part of an other program in PHP.
-
Re: Page replacement algorithm
Still curious though. I'd like to see if what I wrote produces correct results.
Glad to hear that you got your array problem fixed, it was pretty easy to fix, huh?
-
Re: Page replacement algorithm
It is not tested enough yet, I also need the translation from the PHP script
-
Re: Page replacement algorithm
Does that mean I can't know the all of the parameters to the problem? I don't want your work, just a better definition of the problem.
-
Re: Page replacement algorithm
-
Re: Page replacement algorithm
Getting the code I posted now, recently to work without much rewrite.
-
Re: Page replacement algorithm
So you aren't going to tell me more details about the original problem("I have a problem to code a page replacement algorithm simulation in VB.net, I have the random numbers that represent the pages that will be used") like
How much physical memory does it have
Are the pages the ones causing a page fault
What is the arrival rate
OK. Good luck.
The link I posted will tell you every thing you want to know about arrays.
-
Re: Page replacement algorithm
System.NullReferenceException is the problem
-
Re: Page replacement algorithm
The link I posted will tell you every thing you want to know about arrays.