[Mono-devel-list] Processes

Vadim B. Guzev vguzev at yandex.ru
Thu Feb 12 17:41:57 EST 2004


Hello, mono-devel-list at lists.ximian.com!


1.) Can anyone explain me why Mono creates so much threads even on simple
examples?
For example, compile the following example:
8<--------------------------------------------------------------------------
-
using System;

public class A {
 public static void Main ( string[] args ) {
  Console.ReadLine();
 }
}
8<--------------------------------------------------------------------------
-

And run it. When it requests to press "Enter" switch to another console and
do 'ps ux'.
You'll see something like this:

8<--------------------------------------------------------------------------
-
vadim    23826  0.2  0.4 14828 4356 pts/3    S    23:55   0:00 mono a.exe
vadim    23827  0.0  0.2  9328 1876 ?        S    23:55   0:00 mono a.exe
vadim    23828  0.0  0.4 14828 4356 pts/3    S    23:55   0:00 mono a.exe
vadim    23829  0.0  0.4 14828 4356 pts/3    S    23:55   0:00 mono a.exe
vadim    23830  0.8  0.4 14828 4356 pts/3    S    23:55   0:00 mono a.exe
vadim    23834  3.0  0.1  2360 1316 pts/6    S    23:55   0:00 -bash
vadim    23876  0.0  0.0  2536  684 pts/6    R    23:55   0:00 ps ux
8<--------------------------------------------------------------------------
-

5 threads!!! Is't OK? (I'm using Mono 0.29 on Linux)


2.) Compile the following two files:

8<-----------------------------A.cs----------------------------------------
using System;
using System.Diagnostics;

public class A {
 public static void Main ( string[] args ) {
  ProcessStartInfo psi = new ProcessStartInfo();
  psi.FileName = "mono";
  psi.Arguments = "b.exe";

  Process p = new Process();
  p.Start( psi );
 }
}

8<--------------------------------------------------------------------------
-

8<------------------------B.cs---------------------------------------------
using System;
using System.Threading;

public class b {
 public static void Main( string[] args ) {
  Console.WriteLine( "This is b process!" );
  while ( true ) { Thread.Sleep( 1000 ); };
 }
}
8<--------------------------------------------------------------------------
-

mcs a.cs -o a.exe
mcs b.cs -o b.exe

And run a.exe.
Then do 'ps ux'. You'll see that there still exists a process a.exe,
although the application a.exe has finished it's execution:

8<--------------------------------------------------------------------------
-
vadim    24060  0.0  0.2  9348 1900 ?        S    00:45   0:00 mono a.exe
vadim    24064  0.0  0.4 14896 4416 ?        S    00:45   0:00 /usr/bin/mono
b.exe
vadim    24065  0.0  0.4 14896 4416 ?        S    00:45   0:00 /usr/bin/mono
b.exe
vadim    24066  0.0  0.4 14896 4416 ?        S    00:45   0:00 /usr/bin/mono
b.exe
vadim    24067  0.0  0.4 14896 4416 ?        S    00:45   0:00 /usr/bin/mono
b.exe
8<--------------------------------------------------------------------------
-

Why does it happen? Is it a normal behaviour?

This is a very critical questions for our system as the number of
simultaneously running processes there can be big enough. And if mono will
multiply this number by four (five)... you can understand what'll happen...
:-(



Best regards,
Vadim B. Guzev




More information about the Mono-devel-list mailing list