<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>《Goroutine调度实例简要分析》的评论</title>
	<atom:link href="http://tonybai.com/2017/11/23/the-simple-analysis-of-goroutine-schedule-examples/feed/" rel="self" type="application/rss+xml" />
	<link>https://tonybai.com/2017/11/23/the-simple-analysis-of-goroutine-schedule-examples/</link>
	<description>一个程序员的心路历程</description>
	<lastBuildDate>Wed, 25 Mar 2026 09:21:20 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>作者：bigwhite</title>
		<link>https://tonybai.com/2017/11/23/the-simple-analysis-of-goroutine-schedule-examples/#comment-7500</link>
		<dc:creator>bigwhite</dc:creator>
		<pubDate>Tue, 22 Sep 2020 07:20:42 +0000</pubDate>
		<guid isPermaLink="false">http://tonybai.com/?p=2465#comment-7500</guid>
		<description>go 1.14加入了抢占式调度。利用系统信号驱动的。那个例子对于Go 1.14及后续版本不再适用。</description>
		<content:encoded><![CDATA[<p>go 1.14加入了抢占式调度。利用系统信号驱动的。那个例子对于Go 1.14及后续版本不再适用。</p>
]]></content:encoded>
	</item>
	<item>
		<title>作者：wei</title>
		<link>https://tonybai.com/2017/11/23/the-simple-analysis-of-goroutine-schedule-examples/#comment-7499</link>
		<dc:creator>wei</dc:creator>
		<pubDate>Tue, 22 Sep 2020 05:33:51 +0000</pubDate>
		<guid isPermaLink="false">http://tonybai.com/?p=2465#comment-7499</guid>
		<description>用go v1.14版本测试的，虽然设置了runtime.GOMAXPROCS(1)，但是main goroutine里的I got scheduled!依旧能够打印出来。</description>
		<content:encoded><![CDATA[<p>用go v1.14版本测试的，虽然设置了runtime.GOMAXPROCS(1)，但是main goroutine里的I got scheduled!依旧能够打印出来。</p>
]]></content:encoded>
	</item>
	<item>
		<title>作者：namezhang</title>
		<link>https://tonybai.com/2017/11/23/the-simple-analysis-of-goroutine-schedule-examples/#comment-7382</link>
		<dc:creator>namezhang</dc:creator>
		<pubDate>Fri, 06 Sep 2019 03:36:52 +0000</pubDate>
		<guid isPermaLink="false">http://tonybai.com/?p=2465#comment-7382</guid>
		<description>go 1.12.8版本测试，有问题，没法打印，看了下这个morestack也有
  0x10937bd		e8dec1fbff		CALL runtime.morestack_noctxt(SB)
  0x10937c2		ebbc			JMP main.dummy(SB)</description>
		<content:encoded><![CDATA[<p>go 1.12.8版本测试，有问题，没法打印，看了下这个morestack也有<br />
  0x10937bd		e8dec1fbff		CALL runtime.morestack_noctxt(SB)<br />
  0x10937c2		ebbc			JMP main.dummy(SB)</p>
]]></content:encoded>
	</item>
	<item>
		<title>作者：bigwhite</title>
		<link>https://tonybai.com/2017/11/23/the-simple-analysis-of-goroutine-schedule-examples/#comment-7374</link>
		<dc:creator>bigwhite</dc:creator>
		<pubDate>Fri, 21 Jun 2019 12:27:40 +0000</pubDate>
		<guid isPermaLink="false">http://tonybai.com/?p=2465#comment-7374</guid>
		<description>我又测试了一下：
mac(Darwin Kernel Version 13.1.0)下go 1.11.2运行没有问题：

$# go run -gcflags &#039;-N -l&#039; case4.go
I got scheduled!
I got scheduled!
I got scheduled!
I got scheduled!
^Csignal: interrupt


linux下(ubuntu 16.04)，go 1.9.7和go 1.12.5也都没有问题。

# go run -gcflags &#039;-N -l&#039; case4.go
I got scheduled!
I got scheduled!
I got scheduled!
I got scheduled!
^Csignal: interrupt

不知道您用的是啥系统，go compiler啥版本</description>
		<content:encoded><![CDATA[<p>我又测试了一下：<br />
mac(Darwin Kernel Version 13.1.0)下go 1.11.2运行没有问题：</p>
<p>$# go run -gcflags &#8216;-N -l&#8217; case4.go<br />
I got scheduled!<br />
I got scheduled!<br />
I got scheduled!<br />
I got scheduled!<br />
^Csignal: interrupt</p>
<p>linux下(ubuntu 16.04)，go 1.9.7和go 1.12.5也都没有问题。</p>
<p># go run -gcflags &#8216;-N -l&#8217; case4.go<br />
I got scheduled!<br />
I got scheduled!<br />
I got scheduled!<br />
I got scheduled!<br />
^Csignal: interrupt</p>
<p>不知道您用的是啥系统，go compiler啥版本</p>
]]></content:encoded>
	</item>
	<item>
		<title>作者：Mark</title>
		<link>https://tonybai.com/2017/11/23/the-simple-analysis-of-goroutine-schedule-examples/#comment-7373</link>
		<dc:creator>Mark</dc:creator>
		<pubDate>Fri, 21 Jun 2019 03:44:16 +0000</pubDate>
		<guid isPermaLink="false">http://tonybai.com/?p=2465#comment-7373</guid>
		<description>在自己的Mac电脑上运行case4.go，并没有打印输出，请教什么原因？和系统有关系吗？</description>
		<content:encoded><![CDATA[<p>在自己的Mac电脑上运行case4.go，并没有打印输出，请教什么原因？和系统有关系吗？</p>
]]></content:encoded>
	</item>
	<item>
		<title>作者：cat</title>
		<link>https://tonybai.com/2017/11/23/the-simple-analysis-of-goroutine-schedule-examples/#comment-7232</link>
		<dc:creator>cat</dc:creator>
		<pubDate>Tue, 10 Jul 2018 04:32:09 +0000</pubDate>
		<guid isPermaLink="false">http://tonybai.com/?p=2465#comment-7232</guid>
		<description>据说1.12要修改调度方式了, 不再每个函数插入调度代码了.</description>
		<content:encoded><![CDATA[<p>据说1.12要修改调度方式了, 不再每个函数插入调度代码了.</p>
]]></content:encoded>
	</item>
	<item>
		<title>作者：bigwhite</title>
		<link>https://tonybai.com/2017/11/23/the-simple-analysis-of-goroutine-schedule-examples/#comment-7121</link>
		<dc:creator>bigwhite</dc:creator>
		<pubDate>Tue, 06 Feb 2018 00:53:44 +0000</pubDate>
		<guid isPermaLink="false">http://tonybai.com/?p=2465#comment-7121</guid>
		<description>runtime包中有一个函数LockOSThread可以将某个goroutine绑定到当前启动goroutine的线程上，不知道能否满足你的需要。</description>
		<content:encoded><![CDATA[<p>runtime包中有一个函数LockOSThread可以将某个goroutine绑定到当前启动goroutine的线程上，不知道能否满足你的需要。</p>
]]></content:encoded>
	</item>
	<item>
		<title>作者：cheney</title>
		<link>https://tonybai.com/2017/11/23/the-simple-analysis-of-goroutine-schedule-examples/#comment-7120</link>
		<dc:creator>cheney</dc:creator>
		<pubDate>Mon, 05 Feb 2018 14:27:20 +0000</pubDate>
		<guid isPermaLink="false">http://tonybai.com/?p=2465#comment-7120</guid>
		<description>我在用 go 调用 win 的 api。

如果创建窗口的函数使用了 goroutine ， getMessage 函数不一定可以读到消息。怀疑是 getMessage 被放到了别的线程执行。

如果想要非要绑定某个线程执行某个函数，golang 能否做到呢？</description>
		<content:encoded><![CDATA[<p>我在用 go 调用 win 的 api。</p>
<p>如果创建窗口的函数使用了 goroutine ， getMessage 函数不一定可以读到消息。怀疑是 getMessage 被放到了别的线程执行。</p>
<p>如果想要非要绑定某个线程执行某个函数，golang 能否做到呢？</p>
]]></content:encoded>
	</item>
	<item>
		<title>作者：boya</title>
		<link>https://tonybai.com/2017/11/23/the-simple-analysis-of-goroutine-schedule-examples/#comment-7106</link>
		<dc:creator>boya</dc:creator>
		<pubDate>Wed, 24 Jan 2018 09:01:20 +0000</pubDate>
		<guid isPermaLink="false">http://tonybai.com/?p=2465#comment-7106</guid>
		<description>我尝试补全一下：
最后的三个汇编代码的意思：
0x0000 00000 MOVQ    (TLS), CX  // 将该goroutine的g结构体地址放入CX寄存器
0x0009 00009 CMPQ    SP, 16(CX)  //比较SP与g.stackguard0的值, g.stackguard0存着该goroutine的栈顶值。
0x000d 00013 JLS     61 // 如果SP &gt; goroutine的栈顶值，则jump到61这个位置，执行扩展栈

g的结构：
type g struct {
	// Stack parameters.
	// stack describes the actual stack memory: [stack.lo, stack.hi).
	// stackguard0 is the stack pointer compared in the Go stack growth prologue.
	// It is stack.lo+StackGuard normally, but can be StackPreempt to trigger a preemption.
	// stackguard1 is the stack pointer compared in the C stack growth prologue.
	// It is stack.lo+StackGuard on g0 and gsignal stacks.
	// It is ~0 on other goroutine stacks, to trigger a call to morestackc (and crash).
	stack       stack   // offset known to runtime/cgo
	stackguard0 uintptr // offset known to liblink
	stackguard1 uintptr // offset known to liblink
        ....
}</description>
		<content:encoded><![CDATA[<p>我尝试补全一下：<br />
最后的三个汇编代码的意思：<br />
0&#215;0000 00000 MOVQ    (TLS), CX  // 将该goroutine的g结构体地址放入CX寄存器<br />
0&#215;0009 00009 CMPQ    SP, 16(CX)  //比较SP与g.stackguard0的值, g.stackguard0存着该goroutine的栈顶值。<br />
0x000d 00013 JLS     61 // 如果SP &gt; goroutine的栈顶值，则jump到61这个位置，执行扩展栈</p>
<p>g的结构：<br />
type g struct {<br />
	// Stack parameters.<br />
	// stack describes the actual stack memory: [stack.lo, stack.hi).<br />
	// stackguard0 is the stack pointer compared in the Go stack growth prologue.<br />
	// It is stack.lo+StackGuard normally, but can be StackPreempt to trigger a preemption.<br />
	// stackguard1 is the stack pointer compared in the C stack growth prologue.<br />
	// It is stack.lo+StackGuard on g0 and gsignal stacks.<br />
	// It is ~0 on other goroutine stacks, to trigger a call to morestackc (and crash).<br />
	stack       stack   // offset known to runtime/cgo<br />
	stackguard0 uintptr // offset known to liblink<br />
	stackguard1 uintptr // offset known to liblink<br />
        &#8230;.<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>作者：xdeng</title>
		<link>https://tonybai.com/2017/11/23/the-simple-analysis-of-goroutine-schedule-examples/#comment-7015</link>
		<dc:creator>xdeng</dc:creator>
		<pubDate>Thu, 07 Dec 2017 03:28:12 +0000</pubDate>
		<guid isPermaLink="false">http://tonybai.com/?p=2465#comment-7015</guid>
		<description>我以为go的调度是复杂东西，被你这么一说觉得不可思议的简单 :)</description>
		<content:encoded><![CDATA[<p>我以为go的调度是复杂东西，被你这么一说觉得不可思议的简单 <img src='https://tonybai.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
</channel>
</rss>
