Switch to VMWAIT while outputting trace data.

One of the traces from a monkey run suggests we stalled out during the
open/write/close part of writing the trace data.  To reduce the chances
of spin-on-suspending here we now switch to VMWAIT during the I/O.

For bug 2541030.

Change-Id: Ice832988213741976917fdd36afa12a694a42e81
diff --git a/vm/SignalCatcher.c b/vm/SignalCatcher.c
index d3b35b6..2b994da 100644
--- a/vm/SignalCatcher.c
+++ b/vm/SignalCatcher.c
@@ -180,6 +180,12 @@
 
     if (traceBuf != NULL) {
         /*
+         * We don't know how long it will take to do the disk I/O, so put us
+         * into VMWAIT for the duration.
+         */
+        int oldStatus = dvmChangeStatus(dvmThreadSelf(), THREAD_VMWAIT);
+
+        /*
          * Open the stack trace output file, creating it if necessary.  It
          * needs to be world-writable so other processes can write to it.
          */
@@ -200,6 +206,7 @@
         }
 
         free(traceBuf);
+        dvmChangeStatus(dvmThreadSelf(), oldStatus);
     }
 }