[Mono-dev] Mutex Bug
vargaz at gmail.com
Wed Jul 2 19:38:32 UTC 2014
mono used to support this functionality, but the code to do that was very
problematic, and it is disabled in recent mono releases.
On Wed, Jul 2, 2014 at 9:31 PM, Edward Ned Harvey (mono) <
edward.harvey.mono at clevertrove.com> wrote:
> Before anything else ... Can anybody recommend a way to do interprocess
> I would like to confirm this is a bug before I go create a bug report in
> bugzilla. Can anybody please confirm both (a) you get the same behavior,
> and (b) it's not correct behavior?
> I want to make this observation as well: The class in question is
> System.Threading.Mutex. But on the mono class status pages, there seems to
> be no System.Threading.Mutex. So that sounds a little suspicious to me,
> but maybe it's ok? Or maybe I'm overlooking it somehow?
> Here is some sample source code:
> using System;
> using System.Threading;
> namespace FunWithMutex
> class MainClass
> static string mutexName;
> const int numThreads = 5;
> static Thread allThreads = new Thread[numThreads];
> public static void Main(string args)
> mutexName = @"Global\mutex-test-erihjbnkjvwiuehrnkjcxvjhwehiu";
> for (int i=0; i<numThreads; i++)
> allThreads[i] = new Thread(new ThreadStart(DoSomething));
> allThreads[i].Name = "Thread #" + i.ToString();
> static void DoSomething()
> System.Console.Error.WriteLine(Thread.CurrentThread.Name + "
> using (var myMutex = new Mutex(false,mutexName))
> Thread.CurrentThread.Name + " running...");
> Thread.CurrentThread.Name + " finished...");
> When run in windows .NET, you launch several processes that each run the
> above code, and the Mutex will only allow one process to enter at a time.
> When run in Mono, a single process obeys the mutex correctly, but multiple
> processes that are launched concurrently, each have an apparently private
> mutex, because each process will allow a single thread to enter the mutex
> In other words, the mutex *should* provide synchronization across multiple
> processes, but it doesn't. Instead, it only provides synchronization
> across multiple threads within a single process.
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Mono-devel-list