Address translation and page interrupt in operating system page virtual storage management

Keywords: Eclipse Java

1, Purpose of the experiment

Through writing and debugging storage management simulation program to deepen the understanding of storage management scheme. Familiar with virtual storage management of various page elimination algorithm. Through writing and debugging address conversion process simulation program to enhance the understanding of address conversion process. We need to know more about how to realize address conversion in paged storage management and how to deal with page missing interrupt and page replacement algorithm in paged virtual storage management.

2, Experiment content

Design a request page storage management scheme. And write a simulation program to realize it. Generate an instruction address stream that needs to be accessed. It is the address of a series of instructions that need to be accessed. For simplicity, you can generate this sequence appropriately (either manually specified or using a random number generator). FIFO page elimination or LRU algorithm is used in page elimination algorithm, and only the flag bit in page table is modified when a page is eliminated. Instead of judging whether it has been rewritten or not, we will not write it back to auxiliary storage.
The specific methods can be as follows:
(1) Generate an instruction address stream to be accessed or the instruction address stream in Table 2 below.
(2) Specify the appropriate page size (e.g. 1K for 1 page);
(3) Specify the maximum length of the memory page table and initialize the page table; table 1 below
When accessing an address, first calculate the page number of the page where the address is located, and then check the page table to determine whether the page is in main memory - if the page is already in main memory, print the page table; at the same time, output the absolute address. If the page is not in main memory and the page table is full, then the page will be adjusted after the FIFO page obsolete algorithm is eliminated, and the page must be modified. The page table will be printed, and the address will be accessed one by one until all addresses are completed.
The flow chart of the storage management algorithm is as follows:

Assuming that each main memory block of main memory is 1024 bytes, each job in the system is divided into 4 main memory blocks.
The page table is as follows:
Page number mark main memory block number modify mark disk location
0 1 5 0 011
1 1 8 0 012
2 1 9 0 013
3 1 1 0 021
4 0 0 022
5 0 0 023
6 0 0 121
The instruction flow is as follows:
Operation page number page address operation page number page address

  • 0 070 shift 4 053
  • 1 050 + 5 023
  • 2 015 save 1 037
    Save 3 021 take 2 078
    Take 0 056 + 4 001
  • 6 040 saved 6 084

Execute the above sequence of instructions in turn to debug your program. It only simulates the execution of instructions and does not consider the execution of specific operations in the instruction sequence.

3, Experimental environment

Software: eclipse
win10

4, Experimental steps

import java.util.Scanner;

class Yetable{
	public int yeno;
	public int logo;
	public int kuaino;
	public int xiugai;
	public String home;
	public Yetable(int yeno, int logo, int kuaino, int xiugai,
			String home) {
		super();
		this.yeno = yeno;
		this.logo = logo;
		this.kuaino = kuaino;
		this.xiugai = xiugai;
		this.home = home;
	}
	public Yetable(int yeno, int logo,  int xiugai,
			String home) {
		super();
		this.yeno = yeno;
		this.logo = logo;
		this.xiugai = xiugai;
		this.home = home;
	}
}

public class Mainclass {
	public static void main(String[] args) {
		Yetable[] table = new Yetable[7];
		table[0]=new Yetable(0,1,5,0,"011");
		table[1]=new Yetable(1,1,8,0,"012");
		table[2]=new Yetable(2,1,9,0,"013");
		table[3]=new Yetable(3,1,1,0,"021");
		table[4]=new Yetable(4,0,0,"022");
		table[5]=new Yetable(5,0,0,"023");
		table[6]=new Yetable(6,0,0,"121");
		int[] tihuan = new int[]{0,1,2,3};
		int yeno;
		Scanner scan = new Scanner(System.in);
		int dizhi;
		int jueduidizhi;
		int flag=0;
		int a=0;
		System.out.println("Page number  "+"sign  "+"Main memory block number"+"modify flag"+"Disk location");
		for(int j=0;j<table.length;j++){
			System.out.println(table[j].yeno+"    "+table[j].logo+"    "+table[j].kuaino+"      "+table[j].xiugai+"      "+table[j].home);
		}
		while(true){
			System.out.println("Please enter the page number to access:");
			yeno = scan.nextInt();
			System.out.println("Please enter the page address of the page number:");
			dizhi =scan.nextInt();
			for(int i=0;i<table.length;i++){
				if(yeno==table[i].yeno){
					a++;
					if(table[i].logo==1){
						System.out.println("Page number  "+"sign  "+"Main memory block number"+"modify flag"+"Disk location");
						for(int j=0;j<table.length;j++){
							System.out.println(table[j].yeno+"    "+table[j].logo+"    "+table[j].kuaino+"      "+table[j].xiugai+"      "+table[j].home);
						}
						jueduidizhi=table[i].kuaino*1024+dizhi;
						System.out.println("Absolute address:"+jueduidizhi);
						break;
					}else{
						if(flag==4){
							flag=1;
						}
						table[i].logo=1;
						int m=tihuan[flag];
						table[m].logo=0;
						table[i].kuaino=table[m].kuaino;
						table[m].kuaino=0;
						tihuan[flag]=table[i].yeno;
						flag++;
						System.out.println("Page number  "+"sign  "+"Main memory block number"+"modify flag"+"Disk location");
						for(int j=0;j<table.length;j++){
							System.out.println(table[j].yeno+"    "+table[j].logo+"    "+table[j].kuaino+"      "+table[j].xiugai+"      "+table[j].home);
						}
						break;
					}
				}
				
			}
			if(a==0){
				System.out.println("No page number.!");
				continue;
			}
			
		}
		
		
	}

}

5, Experimental results and discussion




The following results are omitted

Published 39 original articles, won praise 3, visited 1478
Private letter follow

Posted by Richard on Wed, 04 Mar 2020 19:24:13 -0800