SlideShare a Scribd company logo
Process & CFS
Process
ProcessProgram in the midst of executionHow to create new processfork(), vfork()exec()
Data structuretask_structProcess descriptor http://lxr.linux.no/linux+v2.6.39/include/linux/sched.h#L1193Priority(prio, static_prio, normal_prio) Scheduling class(sched_class)Scheduling policy(policy)Link parent, child, sibling, group_leader
Data structurethread_infohttp://lxr.linux.no/linux+v2.6.39/arch/arm/include/asm/thread_info.h#L50Describe process data accessed by architecture specific codeDifference among other CPUsManaged informationtask_structflags for scheduling(TIF_SIGPANDING, TIF_NEED_RESCHED)cpu number (for multi processor)preempt_count
Data structurethread_unionhttp://lxr.linux.no/linux+v2.6.39/include/linux/sched.h#L2011Kernel stack & thread_info1 or 2 pages(8KB)Kernel stack size is less then 8K
Process states
Process creation system call fork()Duplicate of the parent's page tablesCreate unique process descriptor for child(pidetc)Copy-on-WriteDelay the copying pagesexec() is called right after fork()vfork()Same as fork() except copying of parent page tableShare parent's address spaceChild first schemeParent is blocked until the child calls exec() or exits
do_fork()Start point of fork
copy_process()
 ThreadImplementation threads as same as standard processesOne thread has own task_structpid/ tgidCreate clone() system callclone(CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND, 0);clone(SIGCHLD, 0); // fork()clone(CLONE_VFORK | CLONE_VM | SIGCHLD, 0); // vfork()
Kernel ThreadsStandard processes running in kernel spaceDo not have an address space(task_struct.mm is NULL)Schedulable, preemptable like normal processkthread_create() for creation
Process Terminationexit()wait(), waitpid()
Scheduling
SchedulingCoopreativevsPreemptive yieldtimesliceIO bound vs CPU boundLow latency vsHigh throughput
Process prioritynice Integer value(-20~19, default 0)High nice value correspond to low priorityrenice, setpriority()Realtime priorityAlways higher priority than normal processesInteger value(0~99)
Process priorityPriority kernel internalInteger value (0~139)nice values[-20~19] are map to [100~139][0~99] for realtime processes
Fairness schedulingRR on static timeslice100ms(0 nice) vs 95ms(1 nice)10ms(19 nice) vs 5ms (20 nice)A user’s 100 processes vs B user’s 1processPer user based schedulingEnable when kernel buildPer thread level schedulingOne nice value down gets 10% more CPU powervruntime(virtual clock)Support CGroupschedulinghttp://www.mjmwired.net/kernel/Documentation/scheduler/sched-design-CFS.txt
Overviewschedule()CoreTTTRuequenedo_fork()wake_up_new_task()TTßTWaitqueueCoreTRuequeneCoreTTRuequeneCoreTTRuequene
tast_structsched_classseched_entitysched_classSched_entityload_weighton_rqvruntimerqload_weightcfs_rqrt_rqload_weight
CFS policySoft real-time policyPosix standardPriority schedulingOne nice level down gets 10% more CPU powerVirtual clockConceptual time considering priorityTask waiting most of time will be scheduled to runTime order is managed by Runqueue
Data structtask_structhttp://lxr.linux.no/linux+v2.6.39/include/linux/sched.h#L1193SCHED_NORMALSCHED_BATCHSCHED_IDLESCHED_FIFOSCHED_RR
Data structsched_classhttp://lxr.linux.no/linux+v2.6.39/include/linux/sched.h#L1056
Data structrqhttp://lxr.linux.no/linux+v2.6.39/kernel/sched.c#L447
Data structsched_entityhttp://lxr.linux.no/linux+v2.6.39/include/linux/sched.h#L1142
Dealing with priorityBasicstatic_prioValue inherited by parent or setprio,normal_prioDynamically changed
Dealing with priorityCode
Computing Load weightsload_weight
RemainingHow to determinevruntimeProcess selectionWhen schedule() function is calledContext switchingSleep and Wake upCgroupHard to understand

More Related Content

What's hot (20)

PDF
systemd
nussbauml
 
PDF
Systemd for developers
Alison Chaiken
 
PPTX
Process management in linux
Mazenetsolution
 
PPT
Process and Threads in Linux - PPT
QUONTRASOLUTIONS
 
PDF
Linux scheduler
Liran Ben Haim
 
PDF
Introduction to systemd
Yusaku OGAWA
 
PDF
Basic of Systemd
Praveen Kumar
 
DOCX
Perf stat windows
Accenture
 
PDF
LISA15: systemd, the Next-Generation Linux System Manager
Alison Chaiken
 
PDF
Linux kernel
Mahmoud Shiri Varamini
 
PDF
USENIX ATC 2017 Performance Superpowers with Enhanced BPF
Brendan Gregg
 
PPTX
Linux kernel debugging
Hao-Ran Liu
 
DOCX
Tier 2 net app baseline design standard revised nov 2011
Accenture
 
PDF
Linux System Monitoring basic commands
Mohammad Rafiee
 
PDF
Systemd: the modern Linux init system you will learn to love
Alison Chaiken
 
ODP
LSA2 - 02 Namespaces
Marian Marinov
 
PPTX
The TCP/IP Stack in the Linux Kernel
Divye Kapoor
 
PDF
Linux kernel debugging
libfetion
 
ODP
Linux monitoring
Mark Veltzer
 
PPT
Process management in os
Miong Lazaro
 
systemd
nussbauml
 
Systemd for developers
Alison Chaiken
 
Process management in linux
Mazenetsolution
 
Process and Threads in Linux - PPT
QUONTRASOLUTIONS
 
Linux scheduler
Liran Ben Haim
 
Introduction to systemd
Yusaku OGAWA
 
Basic of Systemd
Praveen Kumar
 
Perf stat windows
Accenture
 
LISA15: systemd, the Next-Generation Linux System Manager
Alison Chaiken
 
USENIX ATC 2017 Performance Superpowers with Enhanced BPF
Brendan Gregg
 
Linux kernel debugging
Hao-Ran Liu
 
Tier 2 net app baseline design standard revised nov 2011
Accenture
 
Linux System Monitoring basic commands
Mohammad Rafiee
 
Systemd: the modern Linux init system you will learn to love
Alison Chaiken
 
LSA2 - 02 Namespaces
Marian Marinov
 
The TCP/IP Stack in the Linux Kernel
Divye Kapoor
 
Linux kernel debugging
libfetion
 
Linux monitoring
Mark Veltzer
 
Process management in os
Miong Lazaro
 

Viewers also liked (10)

PPTX
Git & GitHub
SangJung Woo
 
PPTX
Syslog
SangJung Woo
 
PPTX
Git & G
SangJung Woo
 
PPTX
오픈 플랫폼 타이젠과 컨트리부션하기(연세대 오픈소스 미니콘서트)
Yoonsoo Kim
 
PPTX
Syslog
SangJung Woo
 
PPTX
Open Source Mini Concert-Session 3-Tizen
Yoonsoo Kim
 
PDF
미디어오늘 저널리즘의미래 연결의 진화 - 매직에코 최형욱
Hugh Choi 최형욱
 
PPTX
Tizen introduction & architecture
Yoonsoo Kim
 
PDF
[Tizen Talk 2016 in Seoul] 바닥서부터 만들어보는 타이젠
SangJung Woo
 
PDF
Internet of things : 세상의 모든것들이 연결되는 날 - 최형욱
Hugh Choi 최형욱
 
Git & GitHub
SangJung Woo
 
Syslog
SangJung Woo
 
Git & G
SangJung Woo
 
오픈 플랫폼 타이젠과 컨트리부션하기(연세대 오픈소스 미니콘서트)
Yoonsoo Kim
 
Syslog
SangJung Woo
 
Open Source Mini Concert-Session 3-Tizen
Yoonsoo Kim
 
미디어오늘 저널리즘의미래 연결의 진화 - 매직에코 최형욱
Hugh Choi 최형욱
 
Tizen introduction & architecture
Yoonsoo Kim
 
[Tizen Talk 2016 in Seoul] 바닥서부터 만들어보는 타이젠
SangJung Woo
 
Internet of things : 세상의 모든것들이 연결되는 날 - 최형욱
Hugh Choi 최형욱
 
Ad

Similar to Linux Process & CF scheduling (20)

PDF
Linux kernel development ch4
huangachou
 
PPTX
Process and CPU Scheduling.pptx it is about Operating system
NishthaShah16
 
PPTX
Linux architecture
ICI Bucharest - roTLD
 
PDF
Linux Internals - Part II
Emertxe Information Technologies Pvt Ltd
 
PDF
CS6401 OPERATING SYSTEMS Unit 2
Kathirvel Ayyaswamy
 
DOCX
Week 11Linux InternalsProcesses, schedulingLecture o.docx
melbruce90096
 
PDF
Scheduling
Ankit Dubey
 
PPT
Linux intro to advance
nil65
 
DOCX
Process scheduling
lodhran-hayat
 
PPTX
381CCS_CHAPTER3_UPDATED king Khalid .pptx
HakimAlHuribi
 
PDF
Cs8493 unit 2
Kathirvel Ayyaswamy
 
PPTX
Operating Systems Process Management.pptx
Sivakumar M
 
PPT
06-scheduling.ppt including multiple CPUs
ssuserb53446
 
PPTX
Processes
RaviRaj339
 
PDF
CH03.pdf
ImranKhan880955
 
PPT
What is-a-computer-process-os
Manish Singh
 
PPTX
operating system module 2 presentation notes
ksamjish
 
PPTX
Lecture_Slide_4.pptx
DiptoRoy21
 
PDF
Chapter 3.pdf
HikaTariku
 
PPTX
OS_module2. .pptx
hariprasad279825
 
Linux kernel development ch4
huangachou
 
Process and CPU Scheduling.pptx it is about Operating system
NishthaShah16
 
Linux architecture
ICI Bucharest - roTLD
 
Linux Internals - Part II
Emertxe Information Technologies Pvt Ltd
 
CS6401 OPERATING SYSTEMS Unit 2
Kathirvel Ayyaswamy
 
Week 11Linux InternalsProcesses, schedulingLecture o.docx
melbruce90096
 
Scheduling
Ankit Dubey
 
Linux intro to advance
nil65
 
Process scheduling
lodhran-hayat
 
381CCS_CHAPTER3_UPDATED king Khalid .pptx
HakimAlHuribi
 
Cs8493 unit 2
Kathirvel Ayyaswamy
 
Operating Systems Process Management.pptx
Sivakumar M
 
06-scheduling.ppt including multiple CPUs
ssuserb53446
 
Processes
RaviRaj339
 
CH03.pdf
ImranKhan880955
 
What is-a-computer-process-os
Manish Singh
 
operating system module 2 presentation notes
ksamjish
 
Lecture_Slide_4.pptx
DiptoRoy21
 
Chapter 3.pdf
HikaTariku
 
OS_module2. .pptx
hariprasad279825
 
Ad

Recently uploaded (20)

PPT
chapter 10.pptkkkkkkkkkkkkkkkkkkkkkkkkkk
trishalasharma7
 
PPTX
Ice Breaking - TEBAK GAMBAR NEW - Ice Breaking
candrawibowo15
 
PPTX
一比一原版(DCU毕业证书)都柏林城市大学毕业证如何办理
Taqyea
 
PPTX
ARENA BOLA 1&2 Contigency Plan - ASTRO Broadcast pptx
SobnavalleKhishmu
 
PDF
Sanchit batra best magician in India For all Events.pdf
Sanchit Batra
 
PDF
WKA #19: Mirror Memoria - "FINALITY" TRANSCRIPT.pdf
Optimistic18
 
DOCX
Virat kohli latest video - Mobile masala
Mobile Masala
 
PDF
Quiz time for prehistoric media: media evolution
KenryAraa
 
PDF
WKA #6: The Adventures - "FOUND FAMILY" TRANSCRIPT.pdf
Optimistic18
 
PPTX
一比一原版(UoD毕业证)邓迪大学毕业证如何办理
Taqyea
 
PDF
Peyton Waddell Scavenger Hunt Presentation.pdf
peytonwaddell94
 
PDF
Waddell Scavenger Hunt Presentation-2.pdf
peytonwaddell94
 
PPTX
Line Up Activity For Kids and Adult.....
cynthiamarasigan
 
PDF
WKA #25: The Adventures - "STALKER PARTY" TRANSCRIPT.pdf
Optimistic18
 
PDF
WKA #18: Mirror Memoria - "TATTOO" TRANSCRIPT.pdf
Optimistic18
 
DOCX
The_Owl_and_the_Crow_Kalila_wa_Dimna.docx from fable
ranamutahir19
 
PPTX
一比一还原普利茅斯大学毕业证/PSU毕业证书2025原版水印成绩单
Taqyea
 
PPTX
OTT Channel Migration_AABC Overview_Operations Briefing.pptx
SobnavalleKhishmu
 
PPTX
Connect to the world.pptx Connect to the world.pptx
IbrahimMohamed321335
 
DOCX
Document for guid3 happy for everyone and will lqugh for fun.docx
satusenjaya
 
chapter 10.pptkkkkkkkkkkkkkkkkkkkkkkkkkk
trishalasharma7
 
Ice Breaking - TEBAK GAMBAR NEW - Ice Breaking
candrawibowo15
 
一比一原版(DCU毕业证书)都柏林城市大学毕业证如何办理
Taqyea
 
ARENA BOLA 1&2 Contigency Plan - ASTRO Broadcast pptx
SobnavalleKhishmu
 
Sanchit batra best magician in India For all Events.pdf
Sanchit Batra
 
WKA #19: Mirror Memoria - "FINALITY" TRANSCRIPT.pdf
Optimistic18
 
Virat kohli latest video - Mobile masala
Mobile Masala
 
Quiz time for prehistoric media: media evolution
KenryAraa
 
WKA #6: The Adventures - "FOUND FAMILY" TRANSCRIPT.pdf
Optimistic18
 
一比一原版(UoD毕业证)邓迪大学毕业证如何办理
Taqyea
 
Peyton Waddell Scavenger Hunt Presentation.pdf
peytonwaddell94
 
Waddell Scavenger Hunt Presentation-2.pdf
peytonwaddell94
 
Line Up Activity For Kids and Adult.....
cynthiamarasigan
 
WKA #25: The Adventures - "STALKER PARTY" TRANSCRIPT.pdf
Optimistic18
 
WKA #18: Mirror Memoria - "TATTOO" TRANSCRIPT.pdf
Optimistic18
 
The_Owl_and_the_Crow_Kalila_wa_Dimna.docx from fable
ranamutahir19
 
一比一还原普利茅斯大学毕业证/PSU毕业证书2025原版水印成绩单
Taqyea
 
OTT Channel Migration_AABC Overview_Operations Briefing.pptx
SobnavalleKhishmu
 
Connect to the world.pptx Connect to the world.pptx
IbrahimMohamed321335
 
Document for guid3 happy for everyone and will lqugh for fun.docx
satusenjaya
 

Linux Process & CF scheduling

Editor's Notes

  • #10: wake_up_new_task; in other words, the task structure is added to the scheduler queue뒤쪽에서 스케줄링에서 설명하겠지만 생성된 프로세스는 무조건 한번은 수행되도록 보장함
  • #11: Check flag – for clone system call parameterDup_task_struct – 실제 복사가 이루어짐Sched_fork – 스케줄링에 관련된 내용이 복사됨(확인요함)
  • #19: Vruntime – 실제 수행된 시간에 prority별로 가중치를 둔 이후, 가장 수행시간이 적은 task 위주로 수행함
  • #23: Prio, normal_proi – 동적으로 변함Static_proi- 고정됨Rt_prioroty – realtime인 경우만설정, 그렇지 않은 경우 0,max 99Sched_entity를 갖는 것은 모든지 스케줄링이 될 수 있음Policy는 cpu에 동작할 때의 정책 –sched_normalCpus_allows – bitfield로 특정 cpu에서 동작하는 것을 제한Tile_slice for realtimeß
  • #25: Nr_running – 현재 큐에 들어있는 태스크 갯수Load – 가중치를 고려한 테스크의 워크로드Clock은 해당 런큐가 주기적으로 스케줄링을 받도록 계산하기 위하여 사용됨Cpu_load는 이전의 워크로드를 기록 – 로드벨런싱, 그룹핑에 쓰임\\
  • #26: 전체 큐의 워크로드런큐 내부적으로 rb를 이용하기 때문에, 그에 필요한 노드On_rq – 현재 스케줄링이 되고 있는지 확인CFS를 구현하기 위하여 필요한 시간 값Task_struct가 sched_entity를 가지고 있기 때문에 스케줄링을 받을 수 있음
  • #29: weight는 load 즉, 우선순위에 대한 가중치이고 inv_weight는 이의 역수(1/weight)에 해당하는 값이다.weight 값은 nice를 통해 지정할 수 있는 우선순위에 대응하는 값이며 (nice level 0일 때: 1024)sched.c 파일의 prio_to_weight[] 배열에 저장되어 있다.참고로 nice (우선순위) 값의 1 차이는 weight 값의 1.25 배 차이이며이는 프로세스가 CPU를 사용하는 시간에 10% 정도 영향을 준다.inv_weight값은 단지 계산을 간편하게 하기 위한 목적으로 도입된 것으로가중치 계산을 위한 나눗셈을 피하기 위해 미리 정해진 충분히 큰 수(2^32)에 나눗셈을 미리 계산해 둔 값이다.