time/s virtual residential
00:00:00 16504 8428
00:01:00 17528 9468
00:02:00 17656 10292
00:03:00 18680 10740
00:04:00 18680 11536
00:05:00 19704 12228
00:06:00 20728 12916
00:07:00 21752 13812
00:08:00 21752 14288
00:09:00 23800 14964
00:10:00 23800 16108
00:11:00 23800 16380
00:12:00 24824 17168
00:13:00 25848 17912
00:14:00 26872 18760
00:15:00 26872 19228
00:16:00 27896 20164
00:17:00 28920 20860
00:18:00 29944 21688
00:19:00 30968 22592
00:20:00 30968 23328
00:21:00 31992 24060
00:22:00 31992 24696
00:23:00 33016 25328
00:24:00 34040 26140
00:25:00 35064 26812
00:26:00 35064 27780
00:27:00 36088 28340
00:28:00 37112 29272
00:29:00 38136 30084
00:30:00 38136 30856
00:31:00 39160 31368
00:32:00 40184 32268
00:33:00 41208 33032
####
#!/usr/bin/perl
use strict;
use warnings;
use Config;
use threads;
use Time::HiRes qw( usleep );
$Config{useithreads} or die('Recompile Perl with threads to run this program.');
foreach my $i (1 .. 100000) {
while ((my $nthreads = scalar threads->list()) >= 10) {
print $nthreads . " running. waiting 1 second.\n";
sleep(1);
foreach my $thread (threads->list(threads::joinable)) {
$thread->join();
}
}
threads->create(\&sub1);
usleep(333333);
foreach my $thread (threads->list(threads::joinable)) {
$thread->join();
}
}
foreach my $thread (threads->list()) {
$thread->join();
}
sub sub1 {
my $sleep_value = int(rand(2) * 100) / 100;
print "thread id " . threads->tid() . ": Start sleeping " . $sleep_value . " seconds\n";
usleep($sleep_value * 1000000);
print "thread id " . threads->tid() . ": Done sleeping " . $sleep_value . " seconds\n";
}
####
Summary of my perl5 (revision 5 version 10 subversion 1) configuration:
Platform:
osname=freebsd, osvers=8.2-release, archname=i386-freebsd-thread-multi-64int
uname='freebsd hal.hsh 8.2-release freebsd 8.2-release #0: wed feb 23 11:54:06 cet 2011 dirk@hal.hsh:exportobjusrsrcsyshal i386 '
config_args='-sde -Dprefix=/usr/local -Darchlib=/usr/local/lib/perl5/5.10.1/mach -Dprivlib=/usr/local/lib/perl5/5.10.1 -Dman3dir=/usr/local/lib/perl5/5.10.1/perl/man/man3 -Dman1dir=/usr/local/man/man1 -Dsitearch=/usr/local/lib/perl5/site_perl/5.10.1/mach -Dsitelib=/usr/local/lib/perl5/site_perl/5.10.1 -Dscriptdir=/usr/local/bin -Dsiteman3dir=/usr/local/lib/perl5/5.10.1/man/man3 -Dsiteman1dir=/usr/local/man/man1 -Ui_malloc -Ui_iconv -Uinstallusrbinperl -Dcc=cc -Duseshrplib -Dinc_version_list=none -Dccflags=-DAPPLLIB_EXP="/usr/local/lib/perl5/5.10.1/BSDPAN" -Doptimize=-O2 -pipe -fno-strict-aliasing -Ud_dosuid -Ui_gdbm -Dusethreads=y -Dusemymalloc=n -Duse64bitint -Dusemultiplicity=y'
hint=recommended, useposix=true, d_sigaction=define
useithreads=define, usemultiplicity=define
useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
use64bitint=define, use64bitall=undef, uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
[...]