@@ -118,10 +118,19 @@ enum
118
118
Grunning ,
119
119
Gsyscall ,
120
120
Gwaiting ,
121
- Gmoribund ,
121
+ Gmoribund_unused , // currently unused, but hardcoded in gdb scripts
122
122
Gdead ,
123
123
};
124
124
enum
125
+ {
126
+ // P status
127
+ Pidle ,
128
+ Prunning ,
129
+ Psyscall ,
130
+ Pgcstop ,
131
+ Pdead ,
132
+ };
133
+ enum
125
134
{
126
135
true = 1 ,
127
136
false = 0 ,
@@ -214,6 +223,7 @@ struct G
214
223
Gobuf sched ;
215
224
uintptr gcstack ; // if status==Gsyscall, gcstack = stackbase to use during gc
216
225
uintptr gcsp ; // if status==Gsyscall, gcsp = sched.sp to use during gc
226
+ byte * gcpc ; // if status==Gsyscall, gcpc = sched.pc to use during gc
217
227
uintptr gcguard ; // if status==Gsyscall, gcguard = stackguard to use during gc
218
228
uintptr stack0 ;
219
229
FuncVal * fnstart ; // initial function
@@ -224,13 +234,11 @@ struct G
224
234
uint32 selgen ; // valid sudog pointer
225
235
int8 * waitreason ; // if status==Gwaiting
226
236
G * schedlink ;
227
- bool readyonstop ;
228
237
bool ispanic ;
229
238
bool issystem ;
230
239
int8 raceignore ; // ignore race detection events
231
240
M * m ; // for debuggers, but offset not hard-coded
232
241
M * lockedm ;
233
- M * idlem ;
234
242
int32 sig ;
235
243
int32 writenbuf ;
236
244
byte * writebuf ;
@@ -259,22 +267,24 @@ struct M
259
267
G * gsignal ; // signal-handling G
260
268
uint32 tls [8 ]; // thread-local storage (for 386 extern register)
261
269
G * curg ; // current running goroutine
270
+ P * p ; // attached P for executing Go code (nil if not executing Go code)
271
+ P * nextp ;
262
272
int32 id ;
263
273
int32 mallocing ;
264
274
int32 throwing ;
265
275
int32 gcing ;
266
276
int32 locks ;
267
277
int32 nomemprof ;
268
- int32 waitnextg ;
269
278
int32 dying ;
270
279
int32 profilehz ;
271
280
int32 helpgc ;
281
+ bool blockingsyscall ;
282
+ bool spinning ;
272
283
uint32 fastrand ;
273
284
uint64 ncgocall ; // number of cgo calls in total
274
285
int32 ncgo ; // number of cgo calls currently in progress
275
286
CgoMal * cgomal ;
276
- Note havenextg ;
277
- G * nextg ;
287
+ Note park ;
278
288
M * alllink ; // on allm
279
289
M * schedlink ;
280
290
uint32 machport ; // Return address for Mach IPC (OS X)
@@ -284,7 +294,6 @@ struct M
284
294
uint32 stackcachecnt ;
285
295
void * stackcache [StackCacheSize ];
286
296
G * lockedg ;
287
- G * idleg ;
288
297
uintptr createstack [32 ]; // Stack that created this thread.
289
298
uint32 freglo [16 ]; // D[i] lsb and F[i]
290
299
uint32 freghi [16 ]; // D[i] msb and F[i+16]
@@ -298,6 +307,8 @@ struct M
298
307
bool racecall ;
299
308
bool needextram ;
300
309
void * racepc ;
310
+ void (* waitunlockf )(Lock * );
311
+ Lock * waitlock ;
301
312
uint32 moreframesize_minalloc ;
302
313
303
314
uintptr settype_buf [1024 ];
@@ -317,7 +328,11 @@ struct P
317
328
{
318
329
Lock ;
319
330
331
+ uint32 status ; // one of Pidle/Prunning/...
320
332
P * link ;
333
+ uint32 tick ; // incremented on every scheduler or system call
334
+ M * m ; // back-link to associated M (nil if idle)
335
+ MCache * mcache ;
321
336
322
337
// Queue of runnable goroutines.
323
338
G * * runq ;
@@ -608,6 +623,7 @@ extern uintptr runtime·zerobase;
608
623
extern G * runtime·allg ;
609
624
extern G * runtime·lastg ;
610
625
extern M * runtime·allm ;
626
+ extern P * * runtime·allp ;
611
627
extern int32 runtime·gomaxprocs ;
612
628
extern bool runtime·singleproc ;
613
629
extern uint32 runtime·panicking ;
0 commit comments