[Mono-list] Mutex example doesn't work

Sergio Blanco Cuaresma sergio-blanco@iespana.es
29 Aug 2003 16:13:08 +0200

Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable

I've tested an example from:


And it doesn't work correctly with Mono. It uses 2 mutex no control 4
threads, lets see each one:

t1Start: Waits to finish until all mutex are released
t2Start: Waits until mutex 1 is released
t3Start: Waits until any mutex is released (1 or 2)
t4Start: Waits until mutex 2 is released

The program launch the 4 threads and Release mutex 1 and then mutex 2.
The output of the program shows:

MutexSample.cs ...
 - Main Owns gM1 and gM2
t1Start started,  Mutex.WaitAll(Mutex[])
t2Start started,  gM1.WaitOne( )
t3Start started,  Mutex.WaitAny(Mutex[])
t4Start started,  gM2.WaitOne( )
 - Main releases gM1
t2Start finished, gM1.WaitOne( )
 - Main releases gM2
t4Start finished, gM2.WaitOne( )

And the program doesn't finish. As we can see only the threads t2 and t4
have finished, so the calls WaitAll and WaitAny of thread t1 and t3
don't work properly.

The code can be found in the web of MS that I have specified at the
beginning of the mail. Is it a bug?


[aka Marble]
 Registered LiNUX user #140941  <>  http://counter.li.org/
 Socio #3274 de HispaLinux  <>  http://www.hispalinux.es
 Miembro de GPL URV  <>  http://www.gplurv.org
 GnuPG key: 0x0ED2CF9D  <>  pgp.escomposlinux.org

Content-Type: application/pgp-signature; name=signature.asc
Content-Description: Esta parte del mensaje =?ISO-8859-1?Q?est=E1?= firmada

Version: GnuPG v1.2.2 (GNU/Linux)