This code is fairly safe. Change $procs to a big number if you want to see it kill your host.
#!perl
use forks;
my $procs = 2;
for (1..$procs) {
threads->new(\&fpu_load);
threads->new(\&cpu_load);
}
sleep 100;
sub fpu_load {
my ($f1, $f2, $sum);
while(1) {
$f1 = rand(1000);
$f2 = rand(1000);
$sum = $f1 * $f2;
}
}
sub cpu_load {
my ($f1, $f2, $sum);
while(1) {
$f1 = rand(1000);
$f2 = rand(1000);
$sum = $f1 * $f2;
}
}
No comments:
Post a Comment