On Sun, 2005-07-31 at 02:36 -0400, ted leslie wrote:
> Unhandled Exception: System.NotImplementedException: The requested feature is 
> not implemented.
> in <0x0001d> System.Threading.Thread:SpinWait (Int32 iterations)
> in <0x00072> ServerClass:StaticMethod ()
> in (wrapper delegate-invoke) System.MulticastDelegate:invoke_void ()
> 
> 
> I tried a Thread.SpinWait / Interrupt demo program ...
> and mono doesn't support SpinWait ? Its an inefficent function, but if 
> someone were to use it
> in MS .Net and expect there code to work on Mono? 

This patch should fix the issue. It doesn't really implement the thing
correctly (it should really have the pause instruction to help
hyperthreaded processors), but it's better than throwing.

> Then having said that,  SpinWait and Interrupt seem to be a matching pair,
> so without SpinWait, what is Interrupt going to be used for? It doesn't seem 
> to Interrupt Sleep().

They have absolutely nothing to do with each other. SpinWait is designed
for spin locking (not really something you would ever do in managed code
-- the standard Monitors can take care of doing spin locks as are best
for the user's machine).

-- Ben
Index: Thread.cs
===================================================================
--- Thread.cs	(revision 47875)
+++ Thread.cs	(working copy)
@@ -626,13 +626,14 @@
 			Resume_internal ();
 		}
 
-		[MonoTODO]
+		[MonoTODO ("Have the jit use the pause instruction here")]
 #if NET_2_0
 		[ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.Success)]
 #endif
 		public static void SpinWait (int iterations) 
 		{
-			throw new NotImplementedException ();
+			for (int i = 0; i < iterations; i ++)
+				/* nop */;
 		}
 
 		public void Start() {
_______________________________________________
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list

Reply via email to