SlideShare a Scribd company logo
1 of 21
Introduction to Go 
Scheduler
Introduction o Go 
• Very easy to use lots of light weight processes 
(Go routines) in the same time. 
• Use the “go” keyword.
Why Not Use System 
Scheduler 
• Processes in an application don’t need too many 
context. 
• It’s difficult for OS to handle too many threads or 
processes. 
• System scheduler is too overhead.
What Will Include 
• Basic structures 
• The init of the scheduler 
• The init of a Go routine 
• The schedule that happens in the system call 
• How to change current running Go routine
Source Code 
• src/pkg/runtime/proc.c 
• src/pkg/runtime/runtime.h 
• src/pkg/runtime/asm_386.s
Basic Structures 
• M: OS threads. 
• P: Context to run Go routines. 
• G: Go routine.
Basic Structures 
M0 M1 M2 
P G 
P 
G0 G 
G0 
G 
G 
G 
G
The Init of Scheduler 
M0 
G0
M0 
G0
runtime·schedinit 
M0 
P P(idle) 
G0
runtime·main 
main·main 
runtime.newproc 
runtime·mstart 
M0 
P P(idle) 
G0 
G 
main 
(run the 
scheduler to 
execute G)
Init of Another Go Routine 
• newproc 
• newproc1 
M0 
P P(idle) 
G0 
G 
main 
G
Init of Another Go Routine 
• newproc 
• newproc1 
• wakep 
• startm(nil, true) 
• newm 
• mstart 
M0 
M1 
P P 
G0 
G 
main 
G0 
G
When to Schedule 
• block system call 
After Go 1.2: 
• call function 
• use a channel
System Call 
• .entersyscallblock 
M0 
M1 
P P 
G0 
G 
main 
G0 
G(sysc 
all) 
G
System Call 
• .entersyscallblock 
• handoffp M0 
P 
G0 
G 
main 
M1 
G(sysc 
all) 
M2 
P(idle) 
G0 
G
System Call 
• .entersyscallblock 
• handoffp 
• startm(p 
M0 
P 
G0 
G 
main 
M1 
G(sysc 
all) 
M2 
P 
G0 
G
How to Change Current Go 
Routine
A Demo
A Demo 
Run with flags: 
• GODEBUG=schedtrace=1000,scheddetail=1 
• GOMAXPROCS=4
Q & A

More Related Content

What's hot

Python and trending_data_ops
Python and trending_data_opsPython and trending_data_ops
Python and trending_data_opschase pettet
 
Where's My Beer: Building a Better Kegerator with a Raspberry Pi & Sensu
Where's My Beer: Building a Better Kegerator with a Raspberry Pi & SensuWhere's My Beer: Building a Better Kegerator with a Raspberry Pi & Sensu
Where's My Beer: Building a Better Kegerator with a Raspberry Pi & SensuSensu Inc.
 
Git and fundamentals
Git and fundamentalsGit and fundamentals
Git and fundamentalsNaincy Gupta
 
Using check json to monitor anything - monitoring house plants
Using check json to monitor anything - monitoring house plants Using check json to monitor anything - monitoring house plants
Using check json to monitor anything - monitoring house plants op5 AB
 
Tài liệu sử dụng GitHub
Tài liệu sử dụng GitHubTài liệu sử dụng GitHub
Tài liệu sử dụng GitHubviet nghiem
 
Pengenalan Git
Pengenalan GitPengenalan Git
Pengenalan Gitfajran
 
Git - The Incomplete Introduction
Git - The Incomplete IntroductionGit - The Incomplete Introduction
Git - The Incomplete Introductionrschwietzke
 
Gitting out of trouble
Gitting out of troubleGitting out of trouble
Gitting out of troubleJon Senchyna
 
Install skyline & Redis in Centos 7
Install skyline & Redis in Centos 7Install skyline & Redis in Centos 7
Install skyline & Redis in Centos 7mytunee
 
Process Management using Circus
Process Management using CircusProcess Management using Circus
Process Management using Circussamof76
 

What's hot (17)

Python and trending_data_ops
Python and trending_data_opsPython and trending_data_ops
Python and trending_data_ops
 
Git basics 2
Git basics 2Git basics 2
Git basics 2
 
C100 k and go
C100 k and goC100 k and go
C100 k and go
 
Where's My Beer: Building a Better Kegerator with a Raspberry Pi & Sensu
Where's My Beer: Building a Better Kegerator with a Raspberry Pi & SensuWhere's My Beer: Building a Better Kegerator with a Raspberry Pi & Sensu
Where's My Beer: Building a Better Kegerator with a Raspberry Pi & Sensu
 
Git and fundamentals
Git and fundamentalsGit and fundamentals
Git and fundamentals
 
ns2-training material
ns2-training materialns2-training material
ns2-training material
 
Now i git it!!!
Now i git it!!!Now i git it!!!
Now i git it!!!
 
Using check json to monitor anything - monitoring house plants
Using check json to monitor anything - monitoring house plants Using check json to monitor anything - monitoring house plants
Using check json to monitor anything - monitoring house plants
 
Tài liệu sử dụng GitHub
Tài liệu sử dụng GitHubTài liệu sử dụng GitHub
Tài liệu sử dụng GitHub
 
Pengenalan Git
Pengenalan GitPengenalan Git
Pengenalan Git
 
Git - The Incomplete Introduction
Git - The Incomplete IntroductionGit - The Incomplete Introduction
Git - The Incomplete Introduction
 
Time Based ACL
Time Based ACLTime Based ACL
Time Based ACL
 
Git for-fun-and-productivity
Git for-fun-and-productivityGit for-fun-and-productivity
Git for-fun-and-productivity
 
Poof
PoofPoof
Poof
 
Gitting out of trouble
Gitting out of troubleGitting out of trouble
Gitting out of trouble
 
Install skyline & Redis in Centos 7
Install skyline & Redis in Centos 7Install skyline & Redis in Centos 7
Install skyline & Redis in Centos 7
 
Process Management using Circus
Process Management using CircusProcess Management using Circus
Process Management using Circus
 

Similar to Introduction to Go scheduler

Hadoop Meetup Jan 2019 - Dynamometer and a Case Study in NameNode GC
Hadoop Meetup Jan 2019 - Dynamometer and a Case Study in NameNode GCHadoop Meetup Jan 2019 - Dynamometer and a Case Study in NameNode GC
Hadoop Meetup Jan 2019 - Dynamometer and a Case Study in NameNode GCErik Krogen
 
PyCon AU 2012 - Debugging Live Python Web Applications
PyCon AU 2012 - Debugging Live Python Web ApplicationsPyCon AU 2012 - Debugging Live Python Web Applications
PyCon AU 2012 - Debugging Live Python Web ApplicationsGraham Dumpleton
 
Git talk from Open 2011 conference in Israel
Git talk from Open 2011 conference in IsraelGit talk from Open 2011 conference in Israel
Git talk from Open 2011 conference in IsraelReuven Lerner
 
國民雲端架構 Django + GAE
國民雲端架構 Django + GAE國民雲端架構 Django + GAE
國民雲端架構 Django + GAEWinston Chen
 
Introduction to Gitlab | Gitlab 101 | Training Session
Introduction to Gitlab | Gitlab 101 | Training SessionIntroduction to Gitlab | Gitlab 101 | Training Session
Introduction to Gitlab | Gitlab 101 | Training SessionAnwarul Islam
 
Git and git workflow best practice
Git and git workflow best practiceGit and git workflow best practice
Git and git workflow best practiceMajid Hosseini
 
What’s eating python performance
What’s eating python performanceWhat’s eating python performance
What’s eating python performancePiotr Przymus
 
Synchronised Multidevice Media Playback with Gstreamer
Synchronised Multidevice Media Playback with GstreamerSynchronised Multidevice Media Playback with Gstreamer
Synchronised Multidevice Media Playback with GstreamerSamsung Open Source Group
 
How to build a feedback loop in software
How to build a feedback loop in softwareHow to build a feedback loop in software
How to build a feedback loop in softwareSandeep Joshi
 
Garbage First Garbage Collector (G1 GC) - Migration to, Expectations and Adva...
Garbage First Garbage Collector (G1 GC) - Migration to, Expectations and Adva...Garbage First Garbage Collector (G1 GC) - Migration to, Expectations and Adva...
Garbage First Garbage Collector (G1 GC) - Migration to, Expectations and Adva...Monica Beckwith
 
The Ring programming language version 1.6 book - Part 12 of 189
The Ring programming language version 1.6 book - Part 12 of 189The Ring programming language version 1.6 book - Part 12 of 189
The Ring programming language version 1.6 book - Part 12 of 189Mahmoud Samir Fayed
 
Working with multiple git repositories
Working with multiple git repositoriesWorking with multiple git repositories
Working with multiple git repositoriesJulien Pivotto
 
Gradle For Beginners (Serbian Developer Conference 2013 english)
Gradle For Beginners (Serbian Developer Conference 2013 english)Gradle For Beginners (Serbian Developer Conference 2013 english)
Gradle For Beginners (Serbian Developer Conference 2013 english)Joachim Baumann
 
Eko10 workshop - OPEN SOURCE DATABASE MONITORING
Eko10 workshop - OPEN SOURCE DATABASE MONITORINGEko10 workshop - OPEN SOURCE DATABASE MONITORING
Eko10 workshop - OPEN SOURCE DATABASE MONITORINGPablo Garbossa
 
marko_go_in_badoo
marko_go_in_badoomarko_go_in_badoo
marko_go_in_badooMarko Kevac
 

Similar to Introduction to Go scheduler (20)

Hadoop Meetup Jan 2019 - Dynamometer and a Case Study in NameNode GC
Hadoop Meetup Jan 2019 - Dynamometer and a Case Study in NameNode GCHadoop Meetup Jan 2019 - Dynamometer and a Case Study in NameNode GC
Hadoop Meetup Jan 2019 - Dynamometer and a Case Study in NameNode GC
 
PyCon AU 2012 - Debugging Live Python Web Applications
PyCon AU 2012 - Debugging Live Python Web ApplicationsPyCon AU 2012 - Debugging Live Python Web Applications
PyCon AU 2012 - Debugging Live Python Web Applications
 
Git talk from Open 2011 conference in Israel
Git talk from Open 2011 conference in IsraelGit talk from Open 2011 conference in Israel
Git talk from Open 2011 conference in Israel
 
國民雲端架構 Django + GAE
國民雲端架構 Django + GAE國民雲端架構 Django + GAE
國民雲端架構 Django + GAE
 
IntroductionGit
IntroductionGitIntroductionGit
IntroductionGit
 
Introduction to Gitlab | Gitlab 101 | Training Session
Introduction to Gitlab | Gitlab 101 | Training SessionIntroduction to Gitlab | Gitlab 101 | Training Session
Introduction to Gitlab | Gitlab 101 | Training Session
 
Git and git workflow best practice
Git and git workflow best practiceGit and git workflow best practice
Git and git workflow best practice
 
What’s eating python performance
What’s eating python performanceWhat’s eating python performance
What’s eating python performance
 
Synchronised Multidevice Media Playback with Gstreamer
Synchronised Multidevice Media Playback with GstreamerSynchronised Multidevice Media Playback with Gstreamer
Synchronised Multidevice Media Playback with Gstreamer
 
How to build a feedback loop in software
How to build a feedback loop in softwareHow to build a feedback loop in software
How to build a feedback loop in software
 
Garbage First Garbage Collector (G1 GC) - Migration to, Expectations and Adva...
Garbage First Garbage Collector (G1 GC) - Migration to, Expectations and Adva...Garbage First Garbage Collector (G1 GC) - Migration to, Expectations and Adva...
Garbage First Garbage Collector (G1 GC) - Migration to, Expectations and Adva...
 
Open source
Open sourceOpen source
Open source
 
The Ring programming language version 1.6 book - Part 12 of 189
The Ring programming language version 1.6 book - Part 12 of 189The Ring programming language version 1.6 book - Part 12 of 189
The Ring programming language version 1.6 book - Part 12 of 189
 
Working with multiple git repositories
Working with multiple git repositoriesWorking with multiple git repositories
Working with multiple git repositories
 
Gradle For Beginners (Serbian Developer Conference 2013 english)
Gradle For Beginners (Serbian Developer Conference 2013 english)Gradle For Beginners (Serbian Developer Conference 2013 english)
Gradle For Beginners (Serbian Developer Conference 2013 english)
 
Java Performance Tuning
Java Performance TuningJava Performance Tuning
Java Performance Tuning
 
Eko10 workshop - OPEN SOURCE DATABASE MONITORING
Eko10 workshop - OPEN SOURCE DATABASE MONITORINGEko10 workshop - OPEN SOURCE DATABASE MONITORING
Eko10 workshop - OPEN SOURCE DATABASE MONITORING
 
marko_go_in_badoo
marko_go_in_badoomarko_go_in_badoo
marko_go_in_badoo
 
Switching to Git
Switching to GitSwitching to Git
Switching to Git
 
Tp cms-g1-v4
Tp cms-g1-v4Tp cms-g1-v4
Tp cms-g1-v4
 

Recently uploaded

AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 

Recently uploaded (20)

AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 

Introduction to Go scheduler

  • 1. Introduction to Go Scheduler
  • 2. Introduction o Go • Very easy to use lots of light weight processes (Go routines) in the same time. • Use the “go” keyword.
  • 3. Why Not Use System Scheduler • Processes in an application don’t need too many context. • It’s difficult for OS to handle too many threads or processes. • System scheduler is too overhead.
  • 4. What Will Include • Basic structures • The init of the scheduler • The init of a Go routine • The schedule that happens in the system call • How to change current running Go routine
  • 5. Source Code • src/pkg/runtime/proc.c • src/pkg/runtime/runtime.h • src/pkg/runtime/asm_386.s
  • 6. Basic Structures • M: OS threads. • P: Context to run Go routines. • G: Go routine.
  • 7. Basic Structures M0 M1 M2 P G P G0 G G0 G G G G
  • 8. The Init of Scheduler M0 G0
  • 11. runtime·main main·main runtime.newproc runtime·mstart M0 P P(idle) G0 G main (run the scheduler to execute G)
  • 12. Init of Another Go Routine • newproc • newproc1 M0 P P(idle) G0 G main G
  • 13. Init of Another Go Routine • newproc • newproc1 • wakep • startm(nil, true) • newm • mstart M0 M1 P P G0 G main G0 G
  • 14. When to Schedule • block system call After Go 1.2: • call function • use a channel
  • 15. System Call • .entersyscallblock M0 M1 P P G0 G main G0 G(sysc all) G
  • 16. System Call • .entersyscallblock • handoffp M0 P G0 G main M1 G(sysc all) M2 P(idle) G0 G
  • 17. System Call • .entersyscallblock • handoffp • startm(p M0 P G0 G main M1 G(sysc all) M2 P G0 G
  • 18. How to Change Current Go Routine
  • 20. A Demo Run with flags: • GODEBUG=schedtrace=1000,scheddetail=1 • GOMAXPROCS=4
  • 21. Q & A