runtime: fix deadlock The deadlock episodically occurs on misc/cgo/test/TestCthread. The problem is that starttheworld() leaves some P's with local work without M's. Then all active M's enter into syscalls, but reject to wake another M's due to the following check (both in entersyscallblock() and in retake()): if(p->runqhead == p->runqtail &&         runtime?atomicload(&runtime?sched.nmspinning) +         runtime?atomicload(&runtime?sched.npidle) > 0)         continue;
runtime: fix deadlock
The deadlock episodically occurs on misc/cgo/test/TestCthread.
The problem is that starttheworld() leaves some P's with local work
without M's. Then all active M's enter into syscalls, but reject to
wake another M's due to the following check (both in entersyscallblock() and in retake()):
if(p->runqhead == p->runqtail &&
        runtime?atomicload(&runtime?sched.nmspinning) +
        runtime?atomicload(&runtime?sched.npidle) > 0)
        continue;

R=rsc
CC=golang-dev
https://codereview.appspot.com/7424054

d0f/go-zh,sanjosh/sanjos100-tipc,glycerine/jeaten-go-arrayof-structof,glycerine/jeaten-go-arrayof-structof,rdp/rogerpack2005-golang,sanjosh/sanjos100-tipc,scirelli/scirelli-go,d0f/go-zh,glycerine/jeaten-go-arrayof-structof,scirelli/scirelli-go,mhennings/marcohennings-go,rdp/rogerpack2005-golang,sanjosh/sanjos100-tipc,mhennings/marcohennings-go,glycerine/jeaten-go-arrayof-structof,rdp/rogerpack2005-golang,mhennings/marcohennings-go,d0f/go-zh,mhennings/marcohennings-go,rdp/rogerpack2005-golang,mhennings/marcohennings-go,mhennings/marcohennings-go,sanjosh/sanjos100-tipc,d0f/go-zh,mhennings/marcohennings-go,webfd/go-zh,webfd/go-zh,webfd/go-zh,bryanxu/go-zh,scirelli/scirelli-go,webfd/go-zh,glycerine/jeaten-go-arrayof-structof,rdp/rogerpack2005-golang,d0f/go-zh,webfd/go-zh,scirelli/scirelli-go,glycerine/jeaten-go-arrayof-structof,bryanxu/go-zh,bryanxu/go-zh,d0f/go-zh,sanjosh/sanjos100-tipc,scirelli/scirelli-go,sanjosh/sanjos100-tipc,bryanxu/go-zh,glycerine/jeaten-go-arrayof-structof,scirelli/scirelli-go,rdp/rogerpack2005-golang,webfd/go-zh,bryanxu/go-zh,sanjosh/sanjos100-tipc,bryanxu/go-zh,webfd/go-zh,d0f/go-zh,bryanxu/go-zh,rdp/rogerpack2005-golang,bryanxu/go-zh,mhennings/marcohennings-go,glycerine/jeaten-go-arrayof-structof,webfd/go-zh,d0f/go-zh,sanjosh/sanjos100-tipc,scirelli/scirelli-go,rdp/rogerpack2005-golang,scirelli/scirelli-go