LEFT | RIGHT |
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 1346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1357 } | 1357 } |
1358 | 1358 |
1359 execute(gp); | 1359 execute(gp); |
1360 } | 1360 } |
1361 | 1361 |
1362 // Puts the current goroutine into a waiting state and calls unlockf. | 1362 // Puts the current goroutine into a waiting state and calls unlockf. |
1363 // If unlockf returns false, the goroutine is resumed. | 1363 // If unlockf returns false, the goroutine is resumed. |
1364 void | 1364 void |
1365 runtime·park(bool(*unlockf)(G*, void*), void *lock, int8 *reason) | 1365 runtime·park(bool(*unlockf)(G*, void*), void *lock, int8 *reason) |
1366 { | 1366 { |
| 1367 if(g->status != Grunning) |
| 1368 runtime·throw("bad g status"); |
1367 m->waitlock = lock; | 1369 m->waitlock = lock; |
1368 m->waitunlockf = unlockf; | 1370 m->waitunlockf = unlockf; |
1369 g->waitreason = reason; | 1371 g->waitreason = reason; |
1370 runtime·mcall(park0); | 1372 runtime·mcall(park0); |
1371 } | 1373 } |
1372 | 1374 |
1373 static bool | 1375 static bool |
1374 parkunlock(G *gp, void *lock) | 1376 parkunlock(G *gp, void *lock) |
1375 { | 1377 { |
1376 USED(gp); | 1378 USED(gp); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1408 stoplockedm(); | 1410 stoplockedm(); |
1409 execute(gp); // Never returns. | 1411 execute(gp); // Never returns. |
1410 } | 1412 } |
1411 schedule(); | 1413 schedule(); |
1412 } | 1414 } |
1413 | 1415 |
1414 // Scheduler yield. | 1416 // Scheduler yield. |
1415 void | 1417 void |
1416 runtime·gosched(void) | 1418 runtime·gosched(void) |
1417 { | 1419 { |
| 1420 if(g->status != Grunning) |
| 1421 runtime·throw("bad g status"); |
1418 runtime·mcall(runtime·gosched0); | 1422 runtime·mcall(runtime·gosched0); |
1419 } | 1423 } |
1420 | 1424 |
1421 // runtime·gosched continuation on g0. | 1425 // runtime·gosched continuation on g0. |
1422 void | 1426 void |
1423 runtime·gosched0(G *gp) | 1427 runtime·gosched0(G *gp) |
1424 { | 1428 { |
1425 gp->status = Grunnable; | 1429 gp->status = Grunnable; |
1426 gp->m = nil; | 1430 gp->m = nil; |
1427 m->curg = nil; | 1431 m->curg = nil; |
1428 runtime·lock(&runtime·sched); | 1432 runtime·lock(&runtime·sched); |
1429 globrunqput(gp); | 1433 globrunqput(gp); |
1430 runtime·unlock(&runtime·sched); | 1434 runtime·unlock(&runtime·sched); |
1431 if(m->lockedg) { | 1435 if(m->lockedg) { |
1432 stoplockedm(); | 1436 stoplockedm(); |
1433 execute(gp); // Never returns. | 1437 execute(gp); // Never returns. |
1434 } | 1438 } |
1435 schedule(); | 1439 schedule(); |
1436 } | 1440 } |
1437 | 1441 |
1438 // Finishes execution of the current goroutine. | 1442 // Finishes execution of the current goroutine. |
1439 // Need to mark it as nosplit, because it runs with sp > stackbase (as runtime·l
essstack). | 1443 // Need to mark it as nosplit, because it runs with sp > stackbase (as runtime·l
essstack). |
1440 // Since it does not return it does not matter. But if it is preempted | 1444 // Since it does not return it does not matter. But if it is preempted |
1441 // at the split stack check, GC will complain about inconsistent sp. | 1445 // at the split stack check, GC will complain about inconsistent sp. |
1442 #pragma textflag NOSPLIT | 1446 #pragma textflag NOSPLIT |
1443 void | 1447 void |
1444 runtime·goexit(void) | 1448 runtime·goexit(void) |
1445 { | 1449 { |
| 1450 if(g->status != Grunning) |
| 1451 runtime·throw("bad g status"); |
1446 if(raceenabled) | 1452 if(raceenabled) |
1447 runtime·racegoend(); | 1453 runtime·racegoend(); |
1448 runtime·mcall(goexit0); | 1454 runtime·mcall(goexit0); |
1449 } | 1455 } |
1450 | 1456 |
1451 // runtime·goexit continuation on g0. | 1457 // runtime·goexit continuation on g0. |
1452 static void | 1458 static void |
1453 goexit0(G *gp) | 1459 goexit0(G *gp) |
1454 { | 1460 { |
1455 gp->status = Gdead; | 1461 gp->status = Gdead; |
(...skipping 1638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3094 if(experiment[i+j] != name[j]) | 3100 if(experiment[i+j] != name[j]) |
3095 goto nomatch; | 3101 goto nomatch; |
3096 if(experiment[i+j] != '\0' && experiment[i+j] != ',') | 3102 if(experiment[i+j] != '\0' && experiment[i+j] != ',') |
3097 goto nomatch; | 3103 goto nomatch; |
3098 return 1; | 3104 return 1; |
3099 } | 3105 } |
3100 nomatch:; | 3106 nomatch:; |
3101 } | 3107 } |
3102 return 0; | 3108 return 0; |
3103 } | 3109 } |
LEFT | RIGHT |