Switch longer OSWaitus to descheduling the thread

Long spins are a waste of CPU. Also when spinning use some yield
instructions, since that might be slightly more efficient.

Change-Id: Ic7b2f33abd7951df535c12303a1b11033b4c4247
diff --git a/services/server/env/fuchsia/osfunc.cc b/services/server/env/fuchsia/osfunc.cc
index c91b77c..bfd3c71 100644
--- a/services/server/env/fuchsia/osfunc.cc
+++ b/services/server/env/fuchsia/osfunc.cc
@@ -409,9 +409,24 @@
 void
 OSWaitus(IMG_UINT32 ui32Timeus)
 {
-	uint64_t start = OSClockus64();
-	while (OSClockus64() - start < ui32Timeus)
-		;
+        // We don't have to worry about interrupt contexts or anything like that, so it's reasonable
+        // to sleep if the desired delay is long enough. 50 microseconds is a reasonable guess about
+        // how long is enough time for another thread to do some useful work after being scheduled
+        // in.
+	if (ui32Timeus > 50)
+	{
+		zx_nanosleep(zx_deadline_after(ZX_USEC(ui32Timeus)));
+	}
+	else
+	{
+		uint64_t start = OSClockus64();
+		while (OSClockus64() - start < ui32Timeus)
+		{
+#if defined(__aarch64__)
+			__asm__ __volatile__("yield");
+#endif
+		}
+	}
 }
 
 void