Hi Jeff,
Robocode is not able to directly put a limit on the CPU usage for the
thread.
A robot runs in its own thread in the JVM. When a robot executes all pending
commands, it is automatically put into sleep. In the battle main loop,
Robocode checks if all robots are in sleep after some time. This time is
controlled by the "CPU constant", which is calculated/benchmarked to take
the processing power and OS into account. If the robot is not in sleep after
"CPU constant" time, it will skip a turn. This means that the robot has not
been called execute() within the time limit. When the robot has skipped too
many turns, it is banned from the battle, i.e. punished, and it will get 0
score.
In the future, we might introduce a mechanism to measure the exact CPU time
used be a robot. The same goes for the memory usage. But currently, the CPU
usage is updated with huge time intervals (e.g. 10-20 milliseconds on
Windows), which means that e.g. 50-200 turns could have taken place before
we receive a new update for the exact CPU usage by the individual thread.
This is too coarse for Robocode (we need the thread-cpu-usage update for
each turn/tick). Hence, the way we do it now is still the best approach for
us. Regarding monitoring memory usage, there is no way to measure this with
the individual thread - currently.
Regards,
- Flemming
-----Oprindelig meddelelse-----
Fra:
robocode-...@googlegroups.com
[mailto:
robocode-...@googlegroups.com] På vegne af casperjeff
Sendt: 12. maj 2010 18:08
Til: robocode-developers
Emne: [robocode-developers] Re: How secure is robocode?