-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPiggy.java
More file actions
36 lines (26 loc) · 973 Bytes
/
Piggy.java
File metadata and controls
36 lines (26 loc) · 973 Bytes
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
public class Piggy extends UserLandProcess{
int number;
public Piggy(int number){
super();
this.number = number;
}
public void main(){
System.out.println("Allocating memory now Oink!!!");
int pointer = OS.allocateMemory(99 * UserLandProcess.PAGE_SIZE).get();
byte[] oink = ("OINK!!! " + number).getBytes();
cooperate();
for(int j=0; j<PCB.MEM_MAP_SIZE-1; j++){
for(int i=0; i<oink.length;i++){
write(pointer+i+(j*UserLandProcess.PAGE_SIZE), oink[i % oink.length]);
}
}
while(true){
cooperate();
// for(int i=0; i<oink.length;i++){
// write(pointer+i+(0*UserLandProcess.PAGE_SIZE), oink[i % oink.length]);
// }
System.out.println("Oink!!! " + number + " pointer = " + pointer);
OS.sleep(1500);
}
}
}