[Mono-list] PFX still doesn't work correctly (in Mono 2.6.4)
Yury Serdyuk
Yury at serdyuk.botik.ru
Wed Jul 7 06:03:35 EDT 2010
Hi !
I have tried again a simple Parallel.For-program using Mono-2.6.4 now
(about old my attempt see
http://lists.ximian.com/pipermail/mono-list/2009-December/044052.html).
But the program still works incorrectly: when needed to launch N
threads, it launches N + 1 threads.
The code is:
> using System;
> using System.Threading;
>
> public class Test_PFX_For {
> public static void Main ( String[] args ) {
> int num_threads = Convert.ToInt32 ( args [ 0 ] );
> Parallel.For ( 0, num_threads, i =>
> {
> long k = 0;
> while ( true ){
> k++;
> k--;
> }
> });
> }
> }
For example, starting the program as
> $ mono Test_PFX_For.exe 1
gives the workload
> top - 13:54:11 up 7 days, 1:00, 2 users, load average: 0.44, 0.10, 0.03
> Tasks: 185 total, 2 running, 182 sleeping, 0 stopped, 1 zombie
> Cpu0 : 0.0%us, 0.0%sy, 0.0%ni,100.0%id, 0.0%wa, 0.0%hi,
> 0.0%si, 0.0%st
> Cpu1 : 0.0%us, 0.3%sy, 0.0%ni, 99.3%id, 0.3%wa, 0.0%hi,
> 0.0%si, 0.0%st
> Cpu2 :100.0%us, 0.0%sy, 0.0%ni, 0.0%id, 0.0%wa, 0.0%hi,
> 0.0%si, 0.0%st
> Cpu3 :100.0%us, 0.0%sy, 0.0%ni, 0.0%id, 0.0%wa, 0.0%hi,
> 0.0%si, 0.0%st
> Cpu4 : 0.0%us, 0.0%sy, 0.0%ni,100.0%id, 0.0%wa, 0.0%hi,
> 0.0%si, 0.0%st
> Cpu5 : 0.0%us, 0.0%sy, 0.0%ni, 99.3%id, 0.0%wa, 0.0%hi,
> 0.7%si, 0.0%st
> Cpu6 : 0.0%us, 0.0%sy, 0.0%ni,100.0%id, 0.0%wa, 0.0%hi,
> 0.0%si, 0.0%st
> Cpu7 : 0.0%us, 0.0%sy, 0.0%ni,100.0%id, 0.0%wa, 0.0%hi,
> 0.0%si, 0.0%st
> Mem: 8180840k total, 1957368k used, 6223472k free, 200808k buffers
> Swap: 2096472k total, 0k used, 2096472k free, 1518724k cached
>
> PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
> 28233 xxx 25 0 3457m 6644 3880 R 200.1 0.1 0:28.23 mono
Starting the program as
> $ mono Test_PFX_For.exe 2
gives
> top - 13:56:23 up 7 days, 1:03, 2 users, load average: 2.19, 0.89, 0.33
> Tasks: 185 total, 2 running, 182 sleeping, 0 stopped, 1 zombie
> Cpu0 : 0.0%us, 0.3%sy, 0.0%ni, 93.0%id, 6.7%wa, 0.0%hi,
> 0.0%si, 0.0%st
> Cpu1 :100.0%us, 0.0%sy, 0.0%ni, 0.0%id, 0.0%wa, 0.0%hi,
> 0.0%si, 0.0%st
> Cpu2 :100.0%us, 0.0%sy, 0.0%ni, 0.0%id, 0.0%wa, 0.0%hi,
> 0.0%si, 0.0%st
> Cpu3 : 0.0%us, 0.0%sy, 0.0%ni,100.0%id, 0.0%wa, 0.0%hi,
> 0.0%si, 0.0%st
> Cpu4 : 0.3%us, 0.3%sy, 0.0%ni, 99.3%id, 0.0%wa, 0.0%hi,
> 0.0%si, 0.0%st
> Cpu5 : 0.0%us, 0.0%sy, 0.0%ni,100.0%id, 0.0%wa, 0.0%hi,
> 0.0%si, 0.0%st
> Cpu6 : 0.0%us, 0.3%sy, 0.0%ni, 99.7%id, 0.0%wa, 0.0%hi,
> 0.0%si, 0.0%st
> Cpu7 :100.0%us, 0.0%sy, 0.0%ni, 0.0%id, 0.0%wa, 0.0%hi,
> 0.0%si, 0.0%st
> Mem: 8180840k total, 1956260k used, 6224580k free, 200808k buffers
> Swap: 2096472k total, 0k used, 2096472k free, 1518736k cached
>
> PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
> 28502 xxx 25 0 3457m 6556 3876 R 299.7 0.1 1:02.78 mono
and so on.
Thanks.
Yury.
More information about the Mono-list
mailing list