OLD | NEW |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 #include "runtime.h" | 5 #include "runtime.h" |
6 #include "arch_GOARCH.h" | 6 #include "arch_GOARCH.h" |
7 #include "zaexperiment.h" | 7 #include "zaexperiment.h" |
8 #include "malloc.h" | 8 #include "malloc.h" |
9 #include "stack.h" | 9 #include "stack.h" |
10 #include "race.h" | 10 #include "race.h" |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 | 230 |
231 runtime·exit(0); | 231 runtime·exit(0); |
232 for(;;) | 232 for(;;) |
233 *(int32*)runtime·main = 0; | 233 *(int32*)runtime·main = 0; |
234 } | 234 } |
235 | 235 |
236 void | 236 void |
237 runtime·goroutineheader(G *gp) | 237 runtime·goroutineheader(G *gp) |
238 { | 238 { |
239 int8 *status; | 239 int8 *status; |
| 240 int64 waitfor; |
240 | 241 |
241 switch(gp->status) { | 242 switch(gp->status) { |
242 case Gidle: | 243 case Gidle: |
243 status = "idle"; | 244 status = "idle"; |
244 break; | 245 break; |
245 case Grunnable: | 246 case Grunnable: |
246 status = "runnable"; | 247 status = "runnable"; |
247 break; | 248 break; |
248 case Grunning: | 249 case Grunning: |
249 status = "running"; | 250 status = "running"; |
250 break; | 251 break; |
251 case Gsyscall: | 252 case Gsyscall: |
252 status = "syscall"; | 253 status = "syscall"; |
253 break; | 254 break; |
254 case Gwaiting: | 255 case Gwaiting: |
255 if(gp->waitreason) | 256 if(gp->waitreason) |
256 status = gp->waitreason; | 257 status = gp->waitreason; |
257 else | 258 else |
258 status = "waiting"; | 259 status = "waiting"; |
259 break; | 260 break; |
260 default: | 261 default: |
261 status = "???"; | 262 status = "???"; |
262 break; | 263 break; |
263 } | 264 } |
264 » runtime·printf("goroutine %D [%s]:\n", gp->goid, status); | 265 |
| 266 » // approx time the G is blocked, in minutes |
| 267 » waitfor = 0; |
| 268 » if((gp->status == Gwaiting || gp->status == Gsyscall) && gp->waitsince !
= 0) |
| 269 » » waitfor = (runtime·nanotime() - gp->waitsince) / (60LL*1000*1000
*1000); |
| 270 |
| 271 » if(waitfor < 1) |
| 272 » » runtime·printf("goroutine %D [%s]:\n", gp->goid, status); |
| 273 » else |
| 274 » » runtime·printf("goroutine %D [%s, %D minutes]:\n", gp->goid, sta
tus, waitfor); |
265 } | 275 } |
266 | 276 |
267 void | 277 void |
268 runtime·tracebackothers(G *me) | 278 runtime·tracebackothers(G *me) |
269 { | 279 { |
270 G *gp; | 280 G *gp; |
271 int32 traceback; | 281 int32 traceback; |
272 | 282 |
273 traceback = runtime·gotraceback(nil); | 283 traceback = runtime·gotraceback(nil); |
274 ········ | 284 ········ |
(...skipping 830 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1105 static void | 1115 static void |
1106 execute(G *gp) | 1116 execute(G *gp) |
1107 { | 1117 { |
1108 int32 hz; | 1118 int32 hz; |
1109 | 1119 |
1110 if(gp->status != Grunnable) { | 1120 if(gp->status != Grunnable) { |
1111 runtime·printf("execute: bad g status %d\n", gp->status); | 1121 runtime·printf("execute: bad g status %d\n", gp->status); |
1112 runtime·throw("execute: bad g status"); | 1122 runtime·throw("execute: bad g status"); |
1113 } | 1123 } |
1114 gp->status = Grunning; | 1124 gp->status = Grunning; |
| 1125 gp->waitsince = 0; |
1115 gp->preempt = false; | 1126 gp->preempt = false; |
1116 gp->stackguard0 = gp->stackguard; | 1127 gp->stackguard0 = gp->stackguard; |
1117 m->p->schedtick++; | 1128 m->p->schedtick++; |
1118 m->curg = gp; | 1129 m->curg = gp; |
1119 gp->m = m; | 1130 gp->m = m; |
1120 | 1131 |
1121 // Check whether the profiler needs to be turned on or off. | 1132 // Check whether the profiler needs to be turned on or off. |
1122 hz = runtime·sched.profilehz; | 1133 hz = runtime·sched.profilehz; |
1123 if(m->profilehz != hz) | 1134 if(m->profilehz != hz) |
1124 runtime·resetcpuprofiler(hz); | 1135 runtime·resetcpuprofiler(hz); |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1528 // from the low-level system calls used by the runtime. | 1539 // from the low-level system calls used by the runtime. |
1529 #pragma textflag NOSPLIT | 1540 #pragma textflag NOSPLIT |
1530 void | 1541 void |
1531 runtime·exitsyscall(void) | 1542 runtime·exitsyscall(void) |
1532 { | 1543 { |
1533 m->locks++; // see comment in entersyscall | 1544 m->locks++; // see comment in entersyscall |
1534 | 1545 |
1535 if(g->isbackground) // do not consider blocked scavenger for deadlock d
etection | 1546 if(g->isbackground) // do not consider blocked scavenger for deadlock d
etection |
1536 incidlelocked(-1); | 1547 incidlelocked(-1); |
1537 | 1548 |
| 1549 g->waitsince = 0; |
1538 if(exitsyscallfast()) { | 1550 if(exitsyscallfast()) { |
1539 // There's a cpu for us, so we can run. | 1551 // There's a cpu for us, so we can run. |
1540 m->p->syscalltick++; | 1552 m->p->syscalltick++; |
1541 g->status = Grunning; | 1553 g->status = Grunning; |
1542 // Garbage collector isn't running (since we are), | 1554 // Garbage collector isn't running (since we are), |
1543 // so okay to clear gcstack and gcsp. | 1555 // so okay to clear gcstack and gcsp. |
1544 g->syscallstack = (uintptr)nil; | 1556 g->syscallstack = (uintptr)nil; |
1545 g->syscallsp = (uintptr)nil; | 1557 g->syscallsp = (uintptr)nil; |
1546 m->locks--; | 1558 m->locks--; |
1547 if(g->preempt) { | 1559 if(g->preempt) { |
(...skipping 1388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2936 if(experiment[i+j] != name[j]) | 2948 if(experiment[i+j] != name[j]) |
2937 goto nomatch; | 2949 goto nomatch; |
2938 if(experiment[i+j] != '\0' && experiment[i+j] != ',') | 2950 if(experiment[i+j] != '\0' && experiment[i+j] != ',') |
2939 goto nomatch; | 2951 goto nomatch; |
2940 return 1; | 2952 return 1; |
2941 } | 2953 } |
2942 nomatch:; | 2954 nomatch:; |
2943 } | 2955 } |
2944 return 0; | 2956 return 0; |
2945 } | 2957 } |
OLD | NEW |