Hi, all:

I'm reading the runtime code, and there are some questions, as shown below:

func globrunqput(gp *g) {
gp.schedlink = 0
if sched.runqtail != 0 {
sched.runqtail.ptr().schedlink.set(gp)    // My question: why? 
                                                                            
  // I feel should be gp.schedlink.set(sched.runqtail.ptr()) .
                                                                            
  // So, the chain is: sched.runqtail => old sched.runqtail.
                                                                            
  // I don't know if it's right (like sched.midle, single linked list).
} else {
sched.runqhead.set(gp)                        // My question: why?
                                                                            
  // Set here the head, and then set the tail.
}
sched.runqtail.set(gp)
sched.runqsize++
}

func globrunqputhead(gp *g) {
gp.schedlink = sched.runqhead
sched.runqhead.set(gp)
if sched.runqtail == 0 {
sched.runqtail.set(gp)                            // My question: why?
                                                                            
  // Set the head, and then set the tail in here.
}
sched.runqsize++
}


Who can answer my question? I'm overwhelmed with gratitude. 

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to