-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPing.java
More file actions
26 lines (23 loc) · 837 Bytes
/
Ping.java
File metadata and controls
26 lines (23 loc) · 837 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
import java.nio.ByteBuffer;
public class Ping extends UserLandProcess{
@Override
public void main(){
while(true){
KernelMessage sendMessage = new KernelMessage(OS.GetPid(), OS.GetPidByName("Pong"), 0, "2".getBytes());
OS.SendMessage(sendMessage);
KernelMessage k = OS.WaitForMessage();
if(k == null){
System.out.println("received is null.");
}
String dataString = new String(k.getData());
int pongVal = Integer.parseInt(dataString);
System.out.println("I am PING, pong = " + pongVal);
try {
Thread.sleep(50);
} catch (Exception e) {
System.out.println(e.toString());
}
cooperate();
}
}
}