时间是我们最重要的资产,对时间的使用和管理决定了我们的个人成长。人的注意力是有限的,我们不能将同一份时间投入到不同的事情中,一旦选择花费时间做一些事情,就不得不放弃做其他事情的可能性。如果我们能够静下心来思考应该如何使用自己的最重要资产,一定能获得更大的个人成长和回报。
Go 面试官:什么是协程,协程和线程的区别和联系?
既要理解线程,还要讲解协程,并且诠释两者间的区别,但是由于提到线程,就必然涉及进程,因此本文将会同时梳理介绍 “进程、协程、协程” 三者的随笔知识,希望能引发大家的一些思考。
从底层到应用,想深入Map这篇文章千万不要错过!
超超经过了一番磨难通过了面试官单例的灵魂拷问,面试官貌似想通过一道场景应用题来考验超超对Golang的容器是否足够熟悉。下面来看看超超是如何解答的吧!
嗯,你觉得 Go 在什么时候会抢占 P?
嗯,你觉得 Go 在什么时候会抢占 P?
前几天我们有聊到《单核 CPU,开两个 Goroutine,其中一个死循环,会怎么样?》的问题,我们在一个细节部分有提到:
有新的小伙伴会产生更多的疑问,那就是在 Go 语言中,是如何抢占 P 的呢,这里面是怎么做的?
The Go runtime scheduler's clever way of dealing with system calls
The Go runtime scheduler’s clever way of dealing with system calls
One of Go’s signature features is goroutines, which are lightweight threads that are managed by the Go runtime. The Go runtime implements goroutines using a M:N work stealing scheduler to multiplex goroutines on to operating system threads. The scheduler has special terminology for three important entities; a G is a goroutine, an M is an OS thread (a ‘machine’), and a P is a ‘processor’, which at its core is a limited resource that must be claimed by an M in order to run Go code. Having a limited supply of Ps is how Go limits how many things it will do at once, so as to not overload the overall system; generally there is one P per actual CPU that the OS reports (the number of Ps is GOMAXPROCS
).
用 Go struct 不能犯的一个低级错误!
用 Go struct 不能犯的一个低级错误!
原创 陈煎鱼 脑子进煎鱼了 3天前
收录于话题
#Go45
#面试题13
大家好,我是煎鱼。
前段时间我分享了 《手撕 Go 面试官:Go 结构体是否可以比较,为什么?》的文章,把基本 Go struct 的比较依据研究了一番。这不,最近有一位读者,遇到了一个关于 struct 的新问题,踩到了雷区。不得解。
Goroutine 泄露的 N 种方法,真刺激!
大家好,我是煎鱼。
前几天分享 Go 群友提问的文章时,有读者在朋友圈下提到,希望我能够针对 Goroutine 泄露这块进行讲解,他在面试的时候经常被问到。
另外我也相信很多小伙伴,在做救火队长时排查过 Goroutine 泄露的问题,因为 Goroutine 作为一个载体,基本跑不了干系。