[Mono-list] Threading ThreadPriority under Mono/Linux vs Windows

Oenren r.oenema at idento.eu
Fri Jun 26 04:53:07 EDT 2009


Currently I’m running Mono on a Slackware 12.2 Linux 2.6.27.7-smp machine.

By running the next code under Mono:

static int Run_1 = 0;
static int Run_2 = 0;
static bool Run = true;

static void Main(string[] args)
{
Console.WriteLine("Running threads..");
      Thread thRun1 = new Thread(new ThreadStart(Run1));
      Thread thRun2 = new Thread(new ThreadStart(Run2));

      if (args.Length > 0)
      {
          thRun2.Priority = ThreadPriority.Highest;
          thRun1.Priority = ThreadPriority.Lowest;
      }

      thRun1.Start();
      thRun2.Start();

      Thread.Sleep(10000);
      Run = false;
      Console.WriteLine("Run1: {0}", Run_1);
      Console.WriteLine("Run2: {0}", Run_2);
      thRun1.Join();
      thRun2.Join();
      Console.ReadLine();
}

private static void Run1()
{
    while(Run)
        Run_1++;
}

private static void Run2()
{
    while(Run)
        Run_2++;
}
 
there are no differences while running this code with or without
threadpriority.

Mono/Linux without threadpriority:
Run1: 941780498
Run2: 851665477

Mono with threadpriority:
Run1: 856894461
Run2: 940867355

When I run this code under Windows there are big differences between running
this code with or without threadpriority.

Windows without threadpriority:
Run1: 380924868
Run2: 204027206

Windows with threadpriority:
Run1: 178413526
Run2: 473683710

Am I missing something here?
I expected the same results with Linux/Mono as the results in Windows.

-- 
View this message in context: http://www.nabble.com/Threading-ThreadPriority-under-Mono-Linux-vs-Windows-tp24216629p24216629.html
Sent from the Mono - General mailing list archive at Nabble.com.



More information about the Mono-list mailing list