>  later today I will Test with 8 processes instead of 8 threads. That
>  way, a process garbage collection won't affect the 7 others. If I'm
>  right  the processor usage should be 100% on all processors. Let see

done :-)

MultipleReader.cs
--------------
using System;
using System.Diagnostics;
using System.Threading;

namespace MultipleReader
{
        class Program
        {
                static void Main(string[] args)
                {
                        Thread[] Threads = new 
Thread[Environment.ProcessorCount];
                        for (int Idx = 0; Idx < Threads.Length; Idx++)
                        {
                                MyThread T = new MyThread(args[0]);
                                Threads[Idx] = new Thread(new 
ThreadStart(T.ThreadEntry));
                        }
                        foreach (Thread T in Threads)
                                T.Start();
                        foreach (Thread T in Threads)
                                T.Join();
                }
        }

        class MyThread
        {
                private string FileName;

                public MyThread(string FileName)
                {
                        this.FileName = FileName;
                }

                public void ThreadEntry()
                {
                        Process myProcess = new Process();
                        // pe-format installed, no need to call mono directly
                        myProcess.StartInfo.FileName = "Reader.exe";
                        myProcess.StartInfo.Arguments = FileName;
                        myProcess.StartInfo.UseShellExecute = false;
                        myProcess.Start();
                        myProcess.WaitForExit();
                }
        }
}
--------------
Reader.cs
--------------
using System.IO;

namespace Reader
{
        class Program
        {
                static void Main(string[] args)
                {
                        string Str;
                        using (StreamReader SR = new StreamReader(args[0]))
                                while ((Str = SR.ReadLine()) != null)
                                        ;
                }
        }
}
--------------

Top output (3 samples)
--------------
top - 09:17:44 up 9 days, 19:30,  4 users,  load average: 3.02, 1.92, 1.42
Tasks:   9 total,   8 running,   1 sleeping,   0 stopped,   0 zombie
Cpu(s): 95.5%us,  4.5%sy,  0.0%ni,  0.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:   4002052k total,  2157076k used,  1844976k free,      592k buffers
Swap:  4000176k total,      188k used,  3999988k free,  1390592k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
22745 root      20   0 41700 6480 3152 R  104  0.2   0:16.41
Reader.exe
22749 root      20   0 41700 6480 3148 R  101  0.2   0:17.07
Reader.exe
22746 root      20   0 41700 6488 3152 R   98  0.2   0:16.80
Reader.exe
22750 root      20   0 41700 6492 3152 R   98  0.2   0:16.80
Reader.exe
22751 root      20   0 41700 6484 3152 R   98  0.2   0:17.04
Reader.exe
22752 root      20   0 41700 6492 3152 R   95  0.2   0:16.84
Reader.exe
22747 root      20   0 41700 6496 3152 R   88  0.2   0:16.12
Reader.exe
22748 root      20   0 41700 6496 3152 R   85  0.2   0:16.27
Reader.exe
22733 root      20   0  506m 9108 3556 S    0  0.2   0:00.18
MultipleReader.


top - 09:17:45 up 9 days, 19:30,  4 users,  load average: 3.02, 1.92, 1.42
Tasks:   9 total,   8 running,   1 sleeping,   0 stopped,   0 zombie
Cpu(s): 95.1%us,  4.9%sy,  0.0%ni,  0.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:   4002052k total,  2157076k used,  1844976k free,      592k buffers
Swap:  4000176k total,      188k used,  3999988k free,  1390592k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
22750 root      20   0 41700 6484 3152 R  104  0.2   0:17.12
Reader.exe
22746 root      20   0 41700 6480 3152 R  101  0.2   0:17.11
Reader.exe
22752 root      20   0 41700 6484 3152 R  101  0.2   0:17.15
Reader.exe
22745 root      20   0 41700 6492 3152 R   98  0.2   0:16.71
Reader.exe
22749 root      20   0 41700 6492 3148 R   98  0.2   0:17.37
Reader.exe
22751 root      20   0 41700 6496 3152 R   98  0.2   0:17.34
Reader.exe
22748 root      20   0 41700 6484 3152 R   85  0.2   0:16.53
Reader.exe
22747 root      20   0 41700 6492 3152 R   82  0.2   0:16.37
Reader.exe
22733 root      20   0  506m 9108 3556 S    0  0.2   0:00.18
MultipleReader.


top - 09:17:45 up 9 days, 19:30,  4 users,  load average: 3.02, 1.92, 1.42
Tasks:   9 total,   8 running,   1 sleeping,   0 stopped,   0 zombie
Cpu(s): 94.7%us,  5.3%sy,  0.0%ni,  0.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:   4002052k total,  2157108k used,  1844944k free,      592k buffers
Swap:  4000176k total,      188k used,  3999988k free,  1390592k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
22745 root      20   0 41700 6492 3152 R  101  0.2   0:17.02
Reader.exe
22751 root      20   0 41700 6504 3152 R  101  0.2   0:17.65
Reader.exe
22746 root      20   0 41700 6492 3152 R   98  0.2   0:17.41
Reader.exe
22747 root      20   0 41700 6488 3152 R   98  0.2   0:16.67
Reader.exe
22750 root      20   0 41700 6496 3152 R   98  0.2   0:17.42
Reader.exe
22752 root      20   0 41700 6496 3152 R   98  0.2   0:17.45
Reader.exe
22749 root      20   0 41700 6496 3148 R   88  0.2   0:17.64
Reader.exe
22748 root      20   0 41700 6488 3152 R   85  0.2   0:16.79
Reader.exe
22733 root      20   0  506m 9108 3556 S    0  0.2   0:00.18
MultipleReader.
--------------

Top is showing some artifacts  when is measuring the individual CPU
time (that's normal).

look at the aggregated CPU usage (3rd row on each sample): 0.0%id

Ok, then there is one question left: is there any way to program this
using threads without the GC interfering? any ideas?

Best regards
        Yanko
_______________________________________________
Mono-list maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-list

Reply via email to