On Tue, Aug 30, 2016 at 10:19 PM, Lin Hao <[email protected]> wrote:
>
> 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).
>
To be honest I don't understand your suggestion. The singly-linked list
starts at sched.runqhead, goes through the schedlink pointers of each G on
the list, and ends at sched.runqtail. Caling
gp.schedlink.set(sched.runqtail.ptr()) won't put gp on the list.
> } else {
> sched.runqhead.set(gp) // My question: why?
>
> // Set here the head, and then set the tail.
>
That is exactly what this code does: sets the head, and then the next line
sets the fail.
> }
> 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.
>
I think you need to express your questions more clearly, as right now I
don't understand them.
Ian
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.