-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProcess.java
More file actions
62 lines (51 loc) · 1.26 KB
/
Process.java
File metadata and controls
62 lines (51 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
public class Process{
//Track the global max page number.
private static int maxPage = 0;
private static int PAGE_SIZE;
private int pID, memSize, pageStart;
Process(int pID, int memSize){
this.pID = pID;
this.memSize = memSize;
pageStart = maxPage;
maxPage += memSize/PAGE_SIZE;
if(memSize % PAGE_SIZE != 0){
maxPage++;
}
}
public int get_pID(){
return pID;
}
public int getMemSize(){
return pID;
}
public int getPageStart(){
return pageStart;
}
public int getPageNumber(int relMemLocation){
if(relMemLocation <= memSize){
return pageStart + (relMemLocation / PAGE_SIZE);
}else{
return -1;
}
}
static public void setPageSize(int pageSize){
PAGE_SIZE = pageSize;
}
public String toString(){
return pID + " " + memSize + " " + pageStart;
}
public int getNextPageNumber(int relMemAddress){
if((getPageNumber(relMemAddress) + 1) * PAGE_SIZE < memSize){
return getPageNumber(relMemAddress) + 1;
}else{
return -1;
}
}
public int getNextPageAddress(int relMemAddress){
if((getPageNumber(relMemAddress) + 1) * PAGE_SIZE < memSize){
return (getPageNumber(relMemAddress) + 1)* PAGE_SIZE;
}else{
return -1;
}
}
}