Home > Back-end >  What is channel the send process in 2020-10-21: go?
What is channel the send process in 2020-10-21: go?

Time:10-22

What is channel the send process in 2020-10-21: go? # # f greatly architects a daily topic

CodePudding user response:

1. To obtain the global lock;
2. Then the enqueue elements (through mobile copy);
3. Release the lock;

CodePudding user response:

Lock the current coroutines first, and then in turn determine executive
1 check channel. Recvq are waiting G in the receiver?
1-1: immediately forward the data to the receiver, and then releases the lock and exit
No: 1-2 to 2

2 check if there is a buffer available?
2-1: the data in the target buffer waiting to be received, and then releases the lock and exit,
2 - no: 2 to 3

3 check whether blocking?
3-1 a non-blocking: give up sending (discard data), and then releases the lock and exit.
3-2 block: a new sudog into the send waiting queue channel, sendq, releases the lock and change the state of G to wait (waiting)
G awakened after the 3-2-1 sent successfully, and then release sudog and return
  • Related