Reduce VM aborts during high CPU stress.
(This was cherry-picked from master
2aa43610 for internal bug
1952616.)
The VM has some timeouts that are meant to kill the current process if
something gets stuck (e.g. a thread grabs a lock and then manages to die
while the rest of the process continues on). These were tripping a
little too easily during some high-load situations.
This changes the order of operations so that we now unlock the "thread
suspend" lock before sending a wakeup broadcast to the condition variable
that threads sleep on. This should make it less likely for a thread to
be running for an extended period while the lock is held. (Relates to
internal bug
1664687.)
This also wraps a couple of things (pthread_create, dlopen) with a state
change to VMWAIT. During high load situations these can take a while to
complete, and we would (with the K-Means Visualizer load generator
running) very occasionally time out.
Augmented the debug output in a couple of minor ways. Updated comments.