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