|
-
Mar 27th, 2008, 11:59 AM
#1
Thread Starter
Junior Member
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
Last edited by USER_--_NAME; Mar 27th, 2008 at 12:06 PM.
-
Mar 27th, 2008, 12:31 PM
#2
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
-
Mar 27th, 2008, 12:41 PM
#3
Thread Starter
Junior Member
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.
-
Mar 27th, 2008, 12:53 PM
#4
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?
-
Mar 27th, 2008, 12:58 PM
#5
Thread Starter
Junior Member
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.?
-
Mar 27th, 2008, 01:08 PM
#6
Re: Page replacement algorithm
version of basic
I can help with 2005 or 2008
-
Mar 27th, 2008, 01:12 PM
#7
Thread Starter
Junior Member
Re: Page replacement algorithm
.NET 2
ASP.net 2
I don't use Visual Studio
-
Mar 27th, 2008, 01:18 PM
#8
Re: Page replacement algorithm
-
Mar 27th, 2008, 01:29 PM
#9
Thread Starter
Junior Member
Re: Page replacement algorithm
I don't use an IDE. I write in notepad and similar.
-
Mar 27th, 2008, 01:45 PM
#10
Fanatic Member
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?
CLanguage; 
IF Post = HelpFull Then
RateMe
Else
Say("Shut UP")
End If
DotNet rocks
VB 6, VB.Net 2003, 2005, 2008, 2010, SQL 2005, WM 5.0,ahem ?OpenRoad?
-
Mar 27th, 2008, 01:57 PM
#11
Thread Starter
Junior Member
Re: Page replacement algorithm
I don't know. Anyway, in such a small program will it really help much?
Maybe I will try it.
-
Mar 27th, 2008, 02:02 PM
#12
Fanatic Member
Re: Page replacement algorithm
The more power to you if you can do it. Good luck
CLanguage; 
IF Post = HelpFull Then
RateMe
Else
Say("Shut UP")
End If
DotNet rocks
VB 6, VB.Net 2003, 2005, 2008, 2010, SQL 2005, WM 5.0,ahem ?OpenRoad?
-
Mar 27th, 2008, 02:31 PM
#13
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.
-
Mar 27th, 2008, 02:43 PM
#14
Thread Starter
Junior Member
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?
-
Mar 27th, 2008, 04:26 PM
#15
Re: Page replacement algorithm
Sure. I should get at least a notation in your project, K.
Last edited by dbasnett; Mar 30th, 2008 at 10:21 AM.
-
Mar 27th, 2008, 04:52 PM
#16
Thread Starter
Junior Member
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)
-
Mar 27th, 2008, 04:59 PM
#17
Re: Page replacement algorithm
You mean the PC you don't have.
Download Visual Basic Express 2008.
-
Mar 27th, 2008, 05:28 PM
#18
Thread Starter
Junior Member
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.
Last edited by USER_--_NAME; Mar 27th, 2008 at 05:40 PM.
-
Mar 27th, 2008, 06:38 PM
#19
Re: Page replacement algorithm
I'll zip and post the whole project.
Last edited by dbasnett; Mar 28th, 2008 at 06:16 PM.
-
Mar 27th, 2008, 08:59 PM
#20
Thread Starter
Junior Member
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)
-
Mar 28th, 2008, 09:40 AM
#21
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.
-
Mar 28th, 2008, 05:49 PM
#22
Re: Page replacement algorithm
Has hooks for simulating programs causing faults. Currently the faulting program is generated randomly.
Last edited by dbasnett; Jul 9th, 2008 at 01:51 PM.
-
Mar 30th, 2008, 08:57 AM
#23
Thread Starter
Junior Member
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.
-
Mar 30th, 2008, 09:02 AM
#24
Re: Page replacement algorithm
why are you working with empty arrays? specific code, specific answers.
-
Mar 30th, 2008, 09:33 AM
#25
Thread Starter
Junior Member
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
%>
-
Mar 30th, 2008, 09:42 AM
#26
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
-
Mar 30th, 2008, 09:50 AM
#27
Thread Starter
Junior Member
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.
-
Mar 30th, 2008, 09:51 AM
#28
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.
-
Mar 30th, 2008, 09:57 AM
#29
Thread Starter
Junior Member
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.
-
Mar 30th, 2008, 10:05 AM
#30
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?
-
Mar 30th, 2008, 10:06 AM
#31
Thread Starter
Junior Member
Re: Page replacement algorithm
It is not tested enough yet, I also need the translation from the PHP script
-
Mar 30th, 2008, 10:08 AM
#32
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.
-
Mar 30th, 2008, 10:10 AM
#33
Re: Page replacement algorithm
-
Mar 30th, 2008, 10:15 AM
#34
Thread Starter
Junior Member
Re: Page replacement algorithm
Getting the code I posted now, recently to work without much rewrite.
-
Mar 30th, 2008, 10:19 AM
#35
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.
Last edited by dbasnett; Mar 30th, 2008 at 10:27 AM.
-
Mar 30th, 2008, 10:21 AM
#36
Thread Starter
Junior Member
Re: Page replacement algorithm
System.NullReferenceException is the problem
-
Mar 30th, 2008, 01:06 PM
#37
Re: Page replacement algorithm
The link I posted will tell you every thing you want to know about arrays.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|