]> Cypherpunks.ru repositories - gostls13.git/blobdiff - src/runtime/proc.c
[dev.garbage] all: merge default (dd5014ed9b01) into dev.garbage
[gostls13.git] / src / runtime / proc.c
index b824f574d948008327e45e59cf7036de1eb69f26..ab6812329fd0d11a840235bf00787947c75bdb57 100644 (file)
@@ -2764,6 +2764,8 @@ static void
 checkdead(void)
 {
        G *gp;
+       P *p;
+       M *mp;
        int32 run, grunning, s;
        uintptr i;
 
@@ -2805,6 +2807,24 @@ checkdead(void)
        runtime·unlock(&runtime·allglock);
        if(grunning == 0)  // possible if main goroutine calls runtime·Goexit()
                runtime·throw("no goroutines (main called runtime.Goexit) - deadlock!");
+
+       // Maybe jump time forward for playground.
+       if((gp = runtime·timejump()) != nil) {
+               runtime·casgstatus(gp, Gwaiting, Grunnable);
+               globrunqput(gp);
+               p = pidleget();
+               if(p == nil)
+                       runtime·throw("checkdead: no p for timer");
+               mp = mget();
+               if(mp == nil)
+                       newm(nil, p);
+               else {
+                       mp->nextp = p;
+                       runtime·notewakeup(&mp->park);
+               }
+               return;
+       }
+
        g->m->throwing = -1;  // do not dump full stacks
        runtime·throw("all goroutines are asleep - deadlock!");
 }