dongzuo4666 2015-09-24 16:11
浏览 53
已采纳

去调度程序填充P的本地运行队列?

Look at this well known image taken from morsmachine.dk/go-scheduler

enter image description here

The gray lists are local runqueues of P. If this queue get empty they will be filled with go routines from the global runqueue.

The Question is, who fills the local runqueue of P?

Scheduler, without synchronisation or every P do it for himself (mutex)?

P.S. The article omits this information.

  • 写回答

1条回答

  • 普通网友 2015-09-24 16:47
    关注

    All of this is taken from src/runtime/proc1.go:

    Function schedule (the scheduler) calls findrunnable which attempts to steal a G from another P. If that fails, it'll return a G from the global run queue. That G is then executed on the "current" M.

    In addition, schedule checks the global run queue occasionally "for fairness":

    // Check the global runnable queue once in a while to ensure fairness.
    // Otherwise two goroutines can completely occupy the local runqueue
    // by constantly respawning each other.
    

    In all of that, only one lock is involved, which is lock(&sched.lock).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法