[Mono-list] Mutex example doesn't work

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


--=-rAVw7Jwif6J+5fEeacMa
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable

I've tested an example from:

http://msdn.microsoft.com/library/default.asp?url=3D/library/en-us/cpguide/=
html/cpconmutex.asp

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?

--=20

[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

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

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)

iD8DBQA/T19zfGXf5g7Sz50RAqnfAKCGBsrSTsdSy+nt2cvtECilAuyUygCcDCJ7
ZV5LMrNCnY6MPpT1Dv3Lfes=
=KPdG
-----END PGP SIGNATURE-----

--=-rAVw7Jwif6J+5fEeacMa--