chan

Posted by 夏泽民

type hchan struct { qcount uint // total data in the queue 当前队列中的数据的个数 dataqsiz uint // size of the circular queue channel环形队列的大小 buf unsafe.Pointer // points to an array of dataqsiz elements 存放数据的环形队列的指针 elemsize uint16 // channel 中存放的数据类型的大小|即每个元素的大小 closed uint32 // channel 是否关闭的标示 elemtype *_type // element type channel中存放的元素的类型 sendx uint // send index 当前发送元素指向channel环形队列的下标指针 recvx uint // receive index 当前接收元素指向channel环形队列的下标指针 recvq waitq // list of recv waiters 等待接收元素的goroutine队列 sendq waitq // list of send waiters 等待发送元素的goroutine队列



bootstrap

Posted by 夏泽民

https://blog.csdn.net/u010853261/article/details/84790392 https://blog.csdn.net/u010853261/article/details/84901386



Scheduler 原理解析

Posted by 夏泽民

Golang Scheduler原理解析 Section1 Scheduler原理 1.基础知识 2.调度模型 3.调度核心问题 Section2 主要模型的源码分析 2.1 实体M 2.2 实体P(processor) 2.3 实体G(goroutine) Section3 主要调度流程的源码分析 3.1 预备知识 3.1.1 golang的函数调用规范 3.1.2 TLS(thread local storage) 3.1.3 栈扩张 3.1.4 写屏障(write barrier) 3.1.5 m0和g0 3.1.6 go中线程的种类 3.2 main线程启动执行 3.3 新建goroutine过程 3.4 循环调度schedule过程 3.5 抢占式调度实现(sysmon线程) Section4:scheduler与memory allocation、channel、garbage collection关联部分 本文主要分析Golang底层对于协程的调度原理,本文与Golang的memory allocation、garbage collection这两个主题是紧密相关的,本文scheduler作为系列的第一篇文章。 文章大体上的思路是这样的: section1:主要图示和文字介绍scheduler的原理; section2:主要模型的角度介绍scheduler原理; section3:从主要调度流程介绍scheduler原理; section4:分析scheduler与memory allocation、channel、garbage collection关联部分 基于源码 Go SDK 1.11



slice

Posted by 夏泽民

在GoLang中,slice2:= slice1等于slice2:= slice1 [:]吗? Do the two following lines of code do the same thing in GoLang? What I want to do is to copy a slice into another one:



race

Posted by 夏泽民

一般并发的bug 有两种,死锁(block)和 竞争(race)



Search

Popular posts

Anything in here will be replaced on browsers that support the canvas element

Recent posts

This blog is maintained by 夏泽民

Get in touch with me at 465474307@qq.com

Subscribe to our mailing list

* indicates required