Redian新闻
>
Full story of GO's three level scheduler
avatar
Full story of GO's three level scheduler# Programming - 葵花宝典
h*8
1
【 以下文字转载自 Seattle 讨论区 】
发信人: hyss68 (hyss), 信区: Seattle
标 题: Chase checking每月收$10 service fee?
发信站: BBS 未名空间站 (Sat Apr 23 19:09:35 2011, 美东)
好久不用以前的WAMU的checking account,现在被转成Chase total checking.今天登录
进去,发现已经被扣了两笔service fee,一笔10刀.打过去客服,被告知policy已改,必须
每月有direct deposit >= $500才免service fee.
各位是不是都在交service fee,或者有多于$500的DD?
avatar
p*y
2
给父母填写了,一样的方法填写的,先填的爸爸的,然后再creat了family申请,结果爸爸
的是中文版的,妈妈的是英文版,不知道怎么会这样?
avatar
c*1
3
如果宋思明这个男人没有家室,没有贪腐,我想我也会喜欢。毕竟是一个很懂讨好女人
的有情趣的男人。但既然有家室还是贪官,不管他在床上多么厉害多么会调情,就只有
鄙视和无耻可以形容。
如果我是编剧,不好意思,我会彻底掀翻你们这些天真的人的假想。
不妨说一说如果我是编剧我会怎样完善这个故事吧。
1.让宋的上级看上海藻,只要有上级出现及需要,宋再浪漫再不舍,还是迫于现实把海
藻拱手相让,而海藻这个可怜的女人,也再一次温顺地屈服于另一个官员的淫威之下,
继续在床上大展风骚和淫荡。
2.小贝受到情感打击,傍上女高官。此高官的级别更在宋和宋的上级之上。这样小贝凭
借当二爷的方便,整垮宋和宋的上级。
3.小贝重新得到海藻,但是两人的芥蒂已经使两人的关系冰冷。小贝报复海藻的背叛,
除了侮辱还有拳打脚踢,最后还把海藻送进了天上人间。
4.在一切故事的结尾,包二爷的女高官也垮了。女高官对小贝是真爱,给小贝安排了后
路,但小贝潜逃未果,精神崩溃,拿刀到街上疯狂砍人,终于被人民警察制服。
5.补一场,海萍买的房是豆腐渣,楼倒了,得以幸存,对人生有了新的认识。
大家说这个故事是不是更精彩更能启发世人呢??(:
我承
avatar
w*2
4
Colony: Apple Won’t Be A “Great Company” In Five Years, Cook A “Mismatch”
By Teresa Rivas
Forrester Research CEO George Colony elaborated his caution about Apple (
AAPL) to the Wall Street Journal, in response to his recent blog post
warning that the company will decline in a post-Steve Jobs era.
In defending his position, Colony said “Tim Cook is a competent and proven
leader but he’s just a mismatch with a charismatically-driven organization
like Apple. Apple will be a very good company five years from now but it won
’t be this great company that we’ve come to know.”
Colony reiterated his stance that too many companies are wrongly assuming
that Apple will continue to be the powerhouse we have come to know,
especially given the evolution of apps. He sees today’s apps as “primitive
forerunners” that will pale in comparison to powerful future offerings.
He explained that he wrote the controversial post “because there’s a
coming war for app Internet ecosystems and of course Apple is going to be
right in the middle of that war,” in a speech yesterday.
Apple is having another tough day of trading, and was recently down 2%.
avatar
k*u
5
这个问题这儿合适么?
谢谢
avatar
c*v
6
From hacker news. 2016.
https://news.ycombinator.com/item?id=12459841
The author's signature: I wrote and maintain the Go arm64, sparc64, and
Solaris ports.
Yes, the kernel scheduler works with threads. But the purpose of a scheduler
(both the kernel's and Go's) is to be invisible to the user. Since Go
programs are user-level programs, the kernel scheduler is invisible to Go,
and this is a very good thing.
The kernel provides an abstraction, independently-executed threads of
execution. These threads are managed by the kernel scheduler to implement
parallelism, guarantee fairness, and do many other things, but all this is
not relevant to Go. What matters is that these threads are concurrent,
independent, and carry their own state.
The Go runtime also provides the user with independently-executed threads of
execution. For various reasons I won't get into it does all this in
userspace rather than transparently using kernel threads (note that gccgo on
some platforms just uses kernel threads). So how does it do it?
Well, for once, forget about Ps. They are an optimization. Let's think how
you can do this without Ps; we'll add them later. And forget about
parallelism too. We're making a toy, strictly GOMAXPROCS=1 implementation
for now.
The runtime has to account for all the goroutines the user has to run. These
exist in the runtime as Gs. There are as many Gs as there are goroutines,
but more than the number the user asked for, since the runtime creates its
own.
Like all programs, Go programs start their life as single-threaded programs.
So we have an arbitrary number of Gs that somehow have to all run on this
single thread. This implementation of Go is cooperativelly-scheduled. That
means that the Go code is never preempted, but code must yield.
But where does it yield? The programmer surely doesn't call runtime.Gosched(
), and yet goroutuines seem to yield somehow. Well the compiler inserts call
into the runtime in various places, e.g. channel send and channel receive
will call into the runtime. In fact they will end up in the scheduler. which
looks at the list of runnable Gs, and if there are any, saves the current
context and it reschedules another on top of the running thread.
How does it reschedule? It changes the execution context, which for Go code
means setting a program counter, a stack pointer, a g in the TLS slot (more
on this later), and some other miscellaneous things.
So this works, but there are some problems. The program eventually ends up
doing system calls like read and write, and these system calls can block for
an unbounded period of time. The programs has many runnable Gs. It would be
good if somehow we could run all this code while some other part of the
program is waiting for the kernel.
So we introduce threads now. We're still at GOMAXPROCS=1 level, but we start
using kernel threads.
In this variant of the implementation, the runtime will check the list of
runnable Gs before issuing a system call. If there are Gs to run, it will
start a new thread. The current thread will do the system calls, as before,
but there will be a new thread that will run the scheduler code (because
this is how we set it up when we started it) that will pick a runnable G,
and execute it.
In the original thread, we block in the system call. Once that completes, we
save the result somewhere, the we exit, and the thread disappears.
This works but it's really wastful. All that thread creation and destruction
. It would be better if we reused threads, and only create new ones if
needed. So to do that, we need to do some accouting, and we need to manage
these threads in some data structure. So we introduce Ms. M stands for
machine -- a machine that will execute Go code. We now have both a list of
Gs, and a list of Ms. Now when we need a thread we first search the Ms, we
might have one available already. Only if we don't we will create another M.
When a system calls resumes, the thread will park itself (parked means it's
not runnable, and the kernel will not schedule it) and insert itself in the
list of available Ms.
The relation between all Gs and Ms is n:m, but we only have one runnable G,
many Gs blocked in system calls, and some Ms that do nothing. We can do
better. We want to run multiple Gs in parallel.
For that, we need to introduce a scheduler lock. Multiple Gs will now enter
the scheduler at the same time, so we need a lock.
It works pretty much the same as before, just concurrent. And this
concurrency will enable parallelism if the hardware has multiple core or
CPUs. Now the relation between Gs and Ms trully is m:n.
But there is a problem now. If we set GOMAXPROCS too high, performance is
bad. We don't get the speed-up we expect. The problem is that many
goroutines now compete for the same scheduler lock. Lock contention is bad
and prevents scalability.
So we introduce Ps, and split up the G:M relation into G:P:M. P stands for
processor.
There is a n:1 relation between Gs and Ps. When a Go program starts, it
creates exactly GOMAXPROCS Ps.
When Go code wants to run, it first has to acquire a P. You can think of
this as "G needs to acquire processor time". When a new goroutine is created
, it's placed in a per-P run queue.
Most of the scheduling is done through per-P run queues. There is still a
global run queue, but the idea is that is seldom used, in general, the per-P
run queue is prefered, and this allows to use a per-P lock instead of a
global lock.
Ms uses these Ps to get their workload. All Ms that run user code have a P,
and use its runqueue and locks to schedule the work. There are more Ms,
however. Ms that don't execute user code, for example when doing a system
call (then you are stuck in the kernel, so you don't run user code) hand off
their P before issuing the system call. Since this P is now free, another M
can grab it and schedule Gs from its run queue.
Now we finally discovered the real Go implementation used today. This design
allows both simple accouting of resources, and it is scalable and
performant.
Hope this clear it up.
Oh, yes, and the g in the TLS slot? The current G is always stored in a
register or a TLS slot. In the function preamble, this G is inspected.
Originally it was done to check for stack overflow, but now it has a dual
purpose. Some other concurrent part of the scheduler measures time spent by
running Gs, and if they run too long, it will set some state in the
corresponding G, so that the next time that G will do a function call, the
function call prolog will detect this and will jump into the scheduler,
descheduling the current goroutine and allowing others to run.
avatar
d*w
7
早关了

【在 h****8 的大作中提到】
: 【 以下文字转载自 Seattle 讨论区 】
: 发信人: hyss68 (hyss), 信区: Seattle
: 标 题: Chase checking每月收$10 service fee?
: 发信站: BBS 未名空间站 (Sat Apr 23 19:09:35 2011, 美东)
: 好久不用以前的WAMU的checking account,现在被转成Chase total checking.今天登录
: 进去,发现已经被扣了两笔service fee,一笔10刀.打过去客服,被告知policy已改,必须
: 每月有direct deposit >= $500才免service fee.
: 各位是不是都在交service fee,或者有多于$500的DD?

avatar
m*9
8
不知道你说的中文是什么用的,我的两个都是有中文也有英文
avatar
d*d
9
你丫就是妒嫉海藻

【在 c***1 的大作中提到】
: 如果宋思明这个男人没有家室,没有贪腐,我想我也会喜欢。毕竟是一个很懂讨好女人
: 的有情趣的男人。但既然有家室还是贪官,不管他在床上多么厉害多么会调情,就只有
: 鄙视和无耻可以形容。
: 如果我是编剧,不好意思,我会彻底掀翻你们这些天真的人的假想。
: 不妨说一说如果我是编剧我会怎样完善这个故事吧。
: 1.让宋的上级看上海藻,只要有上级出现及需要,宋再浪漫再不舍,还是迫于现实把海
: 藻拱手相让,而海藻这个可怜的女人,也再一次温顺地屈服于另一个官员的淫威之下,
: 继续在床上大展风骚和淫荡。
: 2.小贝受到情感打击,傍上女高官。此高官的级别更在宋和宋的上级之上。这样小贝凭
: 借当二爷的方便,整垮宋和宋的上级。

avatar
w*g
10
I do not like cook that much either.
but
sometimes, these wall street anal-ysts deserve to be ass fucked by OWS
movemet mob.

【在 w********2 的大作中提到】
: Colony: Apple Won’t Be A “Great Company” In Five Years, Cook A “Mismatch”
: By Teresa Rivas
: Forrester Research CEO George Colony elaborated his caution about Apple (
: AAPL) to the Wall Street Journal, in response to his recent blog post
: warning that the company will decline in a post-Steve Jobs era.
: In defending his position, Colony said “Tim Cook is a competent and proven
: leader but he’s just a mismatch with a charismatically-driven organization
: like Apple. Apple will be a very good company five years from now but it won
: ’t be this great company that we’ve come to know.”
: Colony reiterated his stance that too many companies are wrongly assuming

avatar
a*a
11
DECT新,1.9G

【在 k*****u 的大作中提到】
: 这个问题这儿合适么?
: 谢谢

avatar
h*i
12
Sounds like to me it is implementing JVM?
LOL, it's all reinventing the wheel over and over again.

scheduler

【在 c*******v 的大作中提到】
: From hacker news. 2016.
: https://news.ycombinator.com/item?id=12459841
: The author's signature: I wrote and maintain the Go arm64, sparc64, and
: Solaris ports.
: Yes, the kernel scheduler works with threads. But the purpose of a scheduler
: (both the kernel's and Go's) is to be invisible to the user. Since Go
: programs are user-level programs, the kernel scheduler is invisible to Go,
: and this is a very good thing.
: The kernel provides an abstraction, independently-executed threads of
: execution. These threads are managed by the kernel scheduler to implement

avatar
c*g
13
我的也是,打电话过去说要关,就给我免了三个月的。过了三个月我在考虑是否留着,
呵呵。
avatar
c*1
14
(:我不是妒忌,我是道德感比较强而已。
澄清一下,我赞赏她的淫荡,否定的是她的堕落。

【在 d********d 的大作中提到】
: 你丫就是妒嫉海藻
avatar
w*c
15
as long as they deliver good products, who cares who's in charge
but +1 for anal-ysts

【在 w*****g 的大作中提到】
: I do not like cook that much either.
: but
: sometimes, these wall street anal-ysts deserve to be ass fucked by OWS
: movemet mob.

avatar
k*u
16
谢谢了
avatar
l*n
17
This is just like thread pools.

scheduler

【在 c*******v 的大作中提到】
: From hacker news. 2016.
: https://news.ycombinator.com/item?id=12459841
: The author's signature: I wrote and maintain the Go arm64, sparc64, and
: Solaris ports.
: Yes, the kernel scheduler works with threads. But the purpose of a scheduler
: (both the kernel's and Go's) is to be invisible to the user. Since Go
: programs are user-level programs, the kernel scheduler is invisible to Go,
: and this is a very good thing.
: The kernel provides an abstraction, independently-executed threads of
: execution. These threads are managed by the kernel scheduler to implement

avatar
f*e
18
不明白宋那么有钱,干嘛不休了大奶,给点钱打发了,娶了海藻,皆大欢喜。
两个人看对眼了没什么,看对眼了还要吊着无辜的另外一个人,这就是萎缩!
avatar
B*e
19
至少比nokia 的 elop 好

【在 w*****g 的大作中提到】
: I do not like cook that much either.
: but
: sometimes, these wall street anal-ysts deserve to be ass fucked by OWS
: movemet mob.

avatar
c*1
20
所以说,从他不肯打发大奶就可以看出,这哪里是什么狗屁真爱,不过是爱自己的宠物
而已。宠物是一种依附。占有了等于自己的财产。

【在 f*********e 的大作中提到】
: 不明白宋那么有钱,干嘛不休了大奶,给点钱打发了,娶了海藻,皆大欢喜。
: 两个人看对眼了没什么,看对眼了还要吊着无辜的另外一个人,这就是萎缩!

avatar
r*a
21
哈哈我怎么觉得这将是一部色情小说,然后最后告诉大家色就是空,空就是色。
男女都要安分守己才重要
avatar
c*1
22
(:
如果观众喜欢,将会有更大量的色情镜头,
最后疯狂归于毁灭
干净利落(:

【在 r*a 的大作中提到】
: 哈哈我怎么觉得这将是一部色情小说,然后最后告诉大家色就是空,空就是色。
: 男女都要安分守己才重要

avatar
r*a
23
宋能发家当上这个小官僚,他老婆家族的势力是个重要的因素
他要是敢离婚,他老婆联合他的政敌会往死里整他的,这样他肯定会基本没有前途,甚
至坐牢的。
这样他还能够保留海藻吗?
所以他是根本不可能离婚的。

【在 f*********e 的大作中提到】
: 不明白宋那么有钱,干嘛不休了大奶,给点钱打发了,娶了海藻,皆大欢喜。
: 两个人看对眼了没什么,看对眼了还要吊着无辜的另外一个人,这就是萎缩!

avatar
c*1
24
所以他到底也是一个出卖自己爱情的小白脸
用他来说什么真爱,简直就是对真爱的侮辱!

【在 r*a 的大作中提到】
: 宋能发家当上这个小官僚,他老婆家族的势力是个重要的因素
: 他要是敢离婚,他老婆联合他的政敌会往死里整他的,这样他肯定会基本没有前途,甚
: 至坐牢的。
: 这样他还能够保留海藻吗?
: 所以他是根本不可能离婚的。

avatar
r*a
25
就是一对萎缩男女,男人为了色女人为了钱,没啥希奇的

【在 c***1 的大作中提到】
: 所以他到底也是一个出卖自己爱情的小白脸
: 用他来说什么真爱,简直就是对真爱的侮辱!

avatar
c*1
26
总之要把价值观的堕落体现得淋漓尽致
实在也只有钱权和女人,真的很三俗

【在 r*a 的大作中提到】
: 就是一对萎缩男女,男人为了色女人为了钱,没啥希奇的
avatar
f*e
27
他老婆家里有势力,那大奶为啥那么关心他?还跑去亲自打小三,直接找几个黑社会生
不见人死不见尸
天下太平。
既然家里有势力,那还不是养一个废一个,嘿嘿。

【在 r*a 的大作中提到】
: 宋能发家当上这个小官僚,他老婆家族的势力是个重要的因素
: 他要是敢离婚,他老婆联合他的政敌会往死里整他的,这样他肯定会基本没有前途,甚
: 至坐牢的。
: 这样他还能够保留海藻吗?
: 所以他是根本不可能离婚的。

avatar
r*a
28
第一,他大奶还是和老公是一个利益共同体,要知道钱都是二个人一块收的,偶尔偷吃
,大奶也就忍了。但是,要把大奶踢下船,换个二奶上台。矛盾的性质就通通变了,大
奶和他的关系就是敌对关系,非要个你死我活不可。
人家那种势力是官场影响力,并不是黑社会影响力。要是敢离,大奶跑到王叔叔,李叔
叔家,一把鼻涕一把眼泪地往人家身上抹,人家王叔叔李叔叔能不烦老宋给他们带来的
麻烦吗?上级领导都烦老宋给他们惹麻烦了,而且老宋这点家里的事情都搞不定,怎么
给领导办事啊? 再说,共产党是明文规定不准包二奶,不准搞婚外恋的。所以老宋失
宠,乃至做牢,差不多是必然的事情了。

【在 f*********e 的大作中提到】
: 他老婆家里有势力,那大奶为啥那么关心他?还跑去亲自打小三,直接找几个黑社会生
: 不见人死不见尸
: 天下太平。
: 既然家里有势力,那还不是养一个废一个,嘿嘿。

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。