Title: VIRTUAL MEMORY
1VIRTUAL MEMORY
Deals with the separation of user logical memory
from physical memory?.
2 Virtual Memory Organisation
of a process
Diagram 1
Page 0
Page 1
Page 2
Other process occupies this space
Physical Memory
Page V
Backing store
Virtual Memory of a process
3- Definitions of the components
- Virtual Memory It is a technique which gives an
- application
program the impression - that it has
contiguous address space - but
physically it is fragmented in the - main memory
and secondary storage - devices.
- Physical Memory It refers to the real storage
and describes -
the total amount of memory installed - in
the computer.Usually consists of -
Random Access Memory (RAM) and -
hard drives.
4- Explanation of diagram 1
- Virtual Memory allocation for a process is
shown in the diagram. - Each process sees one contiguous block of free
memory when it is brought for use. - The program thinks that it has a large range of
contiguous addresses,but in reality the pages are
scattered in the physical memory and the less
active pages are put into the backing store or
the secondary storage disks. - We can see in the diagram how pages in the
virtual memory are scattered in the RAM and the
disks.
5Diagram 2
Diagram taken from Operating system principles
slides by Silverschatz,Galvin and Gagne
6Explanation of step 1
Action Description of the action Audio narration
Reference When the page number is inputted by the user,it is checked in the page table.If it is found there it is said to be referenced. In the animation,searching for the page inputted one by one serially should be shown.
7Explanation of step 2
Action Description of the action Audio narration
Trap The corresponding validation bit is checked.If it is equal to I then a trap is sent to the OS. In the animation,when the validation bit is equal to I,it should be shown clearly that a trap is being sent to the OS.
8Explanation of step 3
Action Description of the action Audio narration
Page is on backing store Once a trap is sent to the OS,the OS decides that the page must be in the backing store.So it starts searching for the page in its backing store. In the animation,search for the page in the backing store should be shown clearly one by one in a serial order.The search should stop only when the page is found or else when all the pages are checked.
9Explanation of step 4
Action Description of the action Audio narration
Bring in missing page If the page is found in the backing store,then a free frame must be found in the physical memory to bring that page in it.Once it is found,the page should be shifted from the backing store to the physical memory. In the animation,the search for a free frame should be shown clearly.once the frame is found then the shifting of page from the backing store to the physical memory should be clearly indicated.
10Explanation of step 5
Action Description of the action Audio narration
Reset Page tables After the page is brought in the physical memory,the page table should be set again.That is,the validation bit which was initially I should be changed to V.this change should be saved and reflected in the further searches. In the animation, the change in the validation bit should be shown clearly.
11Explanation of step 6
Action Description of the action Audio narration
Restart Instruction After the operation on the page requested is dealt with,the prompt should again start asking for new pages so that the instructions can be executed In the animation,after the success/failure is indicated,then the user should again be requested to enter the new page number he wants.
12The proposed animation will look like this
initially
Backing Store
OS
2
3
9
10
Load a process P
0 V
1 v
2 i
3 i
4 v
5 v
6 i
7 v
8 v
9 i
10 i
11 v
12 v
Physical Memory
0
1
4
5
7
8
11
12
Enter the page no
Success/failure
Refresh
Page table
13User Interactivity options
Interactivity Type Options Boundary/Limits Results
Enter the page number It can be a Drop down menu from which user can select page numbers from the list of pages(like 0-12 in this case).Also it can be taken as data inputs from the user. Only one page number can be selected at a time.Multiple selections not allowed.Pages will be entered one by one and handling of each of them will be shown. The list should contain page numbers which are present in the page table (like 0-12)in this example shown. Based on the page number entered by the user,the availability of the page will be told to the user as Success/Failure.4 cases are possible which are shown in the slides 16-31.
14?User Interactivity options
Interactivity Type Option Boundary/ limits Results
Success/failure button After the page number is requested,user will click on this button.The series of steps will be shown and finally the result. This is just a normal button which on pressing will display the results. -------- After the page number is searched,as per the cases possible described in slides the result will be either Successfully found or not found,so abort.
15User interactivity options
Interactivity type Option Boundary/Limit Result
Refresh buttonIf the user wants to start all over again,he/she can press on this button. This is just a normal button. This can be pressed anytime After this button is pressed,a new page table,new backing store,new physical memory with a new set of pages will be created.
16- Case 1
- Suppose the user enters page number 5.
- First the search will begin in the page table.It
will be scanned in serial order one by one as
shown in the diagram. - Once the page is found,its corresponding
valid/invalid bit will be checked. - We see in the example shown that the bit is set
to V in the page table. - So it will display page found message.When the
user clicks on success/failure button,all the
above steps and Success will be displayed. - This case is shown in the next slide with the
help of a diagram.
17The proposed animation will look like this if
Case 1 is encountered
Backing Store
OS
2
3
9
10
Load a process P
0 V
1 v
2 i
3 i
4 v
5 v
6 i
7 v
8 v
9 i
10 i
11 v
12 v
Physical Memory
0
1
4
5
7
8
11
12
Page found,check the bit
Validation bit set to V,Page found successfully.
Enter the page no5
Success/Failure
DisplayPage successfully found
Page table
18- Case 2
- Suppose the entered page number is 2.
- As explained in case 1,the page will be searched
in the page table. - If the page is found,its validation bit will be
checked.In the example given it is set to I. - Now a trap will be sent to the OS.Now OS will
look for this page number in its backing store. - If the page is found there(like in this
example),then a free frame will be searched in
the physical memory. - Once a free frame is found,the page will be
brought from the backing store to the physical
memory. - Page table will be updated.The validation bit
will set to V now and eventually success will be
displayed.(diagram in the next slide)
19The proposed animation will look like this if
Case 2 is encountered
Backing Store
OS
2
3
look in the backing store
found
9
10
Load a process P
0 V
1 v
2 i
3 i
4 v
5 v
6 i
7 v
8 v
9 i
10 i
11 v
12 v
Physical Memory
0
1
4
5
7
8
11
12
Page found,check the bit
Validation bit set to I,trap is sent to the OS.
Free frame is found
Enter the page no2
Success/Failure
Page table
20The proposed animation will look like this if
Case 2 is encountered
Backing Store
OS
3
Page 2 is removed from here.
9
10
Load a process P
0 V
1 v
2 i
3 i
4 v
5 v
6 i
7 v
8 v
9 i
10 i
11 v
12 v
Physical Memory
0
1
4
5
7
8
11
12
2
Page found,check the bit
Free frame is found
Enter the page no2
Page 2 is put in the free frame
Success/Failure
Page table
21The proposed animation will look like this if
Case 2 is encountered
Backing Store
OS
3
Page 2 is removed from here.
9
10
Load a process P
0 V
1 v
2 V
3 i
4 v
5 v
6 i
7 v
8 v
9 i
10 i
11 v
12 v
Physical Memory
0
1
4
5
7
8
11
12
2
Page found,check the bit
Validation bit set to V now,page table is updated
.
Free frame is found
Enter the page no2
Page 2 is put in the free frame
Success/Failure
Page table
22The proposed animation will look like this if
Case 2 is encountered
Backing Store
OS
3
Page 2 is removed from here.
9
10
Load a process P
0 V
1 v
2 V
3 i
4 v
5 v
6 i
7 v
8 v
9 i
10 i
11 v
12 v
Physical Memory
0
1
4
5
7
8
11
12
2
Page found,check the bit
Validation bit set to V now,page table is updated
.
Free frame is found
Enter the page no2
Page 2 is put in the free frame
Success/Failure
DisplayPage successfully found
Now success is displayed.
Page table
23- Case 3
- Suppose the entered page number is 6.
- As explained in case 1,the page will be searched
in the page table. - If the page is found,its validation bit will be
checked.In the example given it is set to I. - Now a trap will be sent to the OS.Now OS will
look for this page number in its backing store. - If the page is not found there(like in this
example),then the process will be aborted and
failure will be displayed. - Diagram is shown in the next slide.
24The proposed animation will look like this if
Case 3 is encountered
Backing Store
OS
2
3
9
10
Load a process P
0 V
1 v
2 v
3 i
4 v
5 v
6 i
7 v
8 v
9 i
10 i
11 v
12 v
Physical Memory
0
1
4
5
7
8
11
12
Page found,check the bit
Validation bit set to I,trap is sent to OS
Enter the page no5
Success/Failure
Page table
25The proposed animation will look like this if
Case 3 is encountered
Backing Store
OS
2
3
Check in the backing store
Search over,page 6 is not there
9
10
Load a process P
0 V
1 v
2 v
3 i
4 v
5 v
6 i
7 v
8 v
9 i
10 i
11 v
12 v
Physical Memory
0
1
4
5
7
8
11
12
Page found,check the bit
Validation bit set to I,trap is sent to OS
Enter the page no5
Success/Failure
Page table
26The proposed animation will look like this if
Case 3 is encountered
Backing Store
OS
2
3
Check in the backing store
Search over,page 6 is not there
9
10
Load a process P
0 V
1 v
2 v
3 i
4 v
5 v
6 i
7 v
8 v
9 i
10 i
11 v
12 v
Physical Memory
0
1
4
5
7
8
11
12
Page found,check the bit
Validation bit set to I,trap is sent to OS
Enter the page no5
Success/Failure
Process is aborted,failure is displayed
Page table
27The proposed animation will look like this if
Case 3 is encountered
Backing Store
OS
2
3
Check in the backing store
Search over,page 6 is not there
9
10
Load a process P
0 V
1 v
2 v
3 i
4 v
5 v
6 i
7 v
8 v
9 i
10 i
11 v
12 v
Physical Memory
0
1
4
5
7
8
11
12
Page found,check the bit
Validation bit set to I,trap is sent to OS
Enter the page no5
Success/FailurePage not found,Failure
Process is aborted,failure is displayed
Page table
28- Case 4
- Suppose the user enters page number 2 again.
- Important point to note here is that once the
page table is updated,its contents are saved. - So now again we will find page 2 in the page
table. - After the search is over and page 2 is found,we
check its validation bit.As the page has been
referenced before,its bit will be already set to
V this time. - So success will be displayed eventually.
- Diagram shown in the next slide.
29The proposed animation will look like this if
Case 4 is encountered
Backing Store
OS
3
9
10
Load a process P
0 V
1 v
2 V
3 i
4 v
5 v
6 i
7 v
8 v
9 i
10 i
11 v
12 v
Physical Memory
0
1
4
5
7
8
11
12
2
Page found,check the bit
Validation bit set to V,Success will be displayed
Enter the page no2
Success/Failure
Page table
30The proposed animation will look like this if
Case 4 is encountered
Backing Store
OS
3
9
10
Load a process P
0 V
1 v
2 V
3 i
4 v
5 v
6 i
7 v
8 v
9 i
10 i
11 v
12 v
Physical Memory
0
1
4
5
7
8
11
12
2
Page found,check the bit
Validation bit set to V,Success will be displayed
Enter the page no2
Success/FailureSuccess,Page found
Page table
31- NOTE
- In the animation,we can generate random entries
in the page table for every new user.That is,the
pages might have different values of the
validation bit once the animation is refreshed. - So consequently,based on the value of the
validation bit,the pages present in the backing
store will change.Only those pages should be
there whose validation bit is set to I. - Also those pages which have validation bit equal
to V,only those should be present in the Physical
memory. - We should also generate some pages whose
validation bit is I,but it is not present in the
backing store.Thus failure can also be shown for
better understanding of the user. - Once updation is done in the page table it should
be saved and the change should be reflected in
all the subsequent search till the refresh button
is pressed. - In the case considered in the previous slides,I
have assumed that only one user is working and he
is entering the page numbers one by one.He has
entered pages 5,2,6 and 2 again without pressing
the refresh button.
32- Questionnaire
- 1.Which is bigger,virtual memory or physical
memory? - a)virtual memory
- b)physical memory
- c)maybe any of them
- 2.How are the pages actually kept in the physical
memory which are referenced in the virtual
memory? - a)contiguously
- b)non contiguously
- c)cant say
- 3.If a page is found in the page table and its
validation bit is V what further steps will take
place? - a)a trap will be sent to the OS and backing
store will be checked - b)a success message will be displayed
- c)Page table will be updated
- 4.If a page is found in the page table and its
validation bit is I what further steps will take
place?
335.If the page has validation bit I and it is not
there in the backing store,what will happen?
a)success will be displayed b)failure will be
displayed c)new frame will be searched in the
physical memory Answers 1 a 2 b 3 b 4
a 5 b
34Links for further reading en.wikipedia.org/wik
i/virtual _ memory Books Operating system
principles by Silverschatz,Galvin and Gagne