SlideShare une entreprise Scribd logo
1  sur  29
Process & CFS
Process
Process Program in the midst of execution How to create new process fork(), vfork() exec()
Data structure task_struct Process descriptor http://lxr.linux.no/linux+v2.6.39/include/linux/sched.h#L1193 Priority(prio, static_prio, normal_prio)  Scheduling class(sched_class) Scheduling policy(policy) Link parent, child, sibling, group_leader
Data structure thread_infohttp://lxr.linux.no/linux+v2.6.39/arch/arm/include/asm/thread_info.h#L50 Describe process data accessed by architecture specific code Difference among other CPUs Managed information task_struct flags for scheduling(TIF_SIGPANDING, TIF_NEED_RESCHED) cpu number (for multi processor) preempt_count
Data structure thread_unionhttp://lxr.linux.no/linux+v2.6.39/include/linux/sched.h#L2011 Kernel stack & thread_info 1 or 2 pages(8KB) Kernel stack size is less then 8K
Process states
Process creation system call  fork() Duplicate of the parent's page tables Create unique process descriptor for child(pidetc) Copy-on-Write Delay the copying pages exec() is called right after fork() vfork() Same as fork() except copying of parent page table Share parent's address space Child first scheme Parent is blocked until the child calls exec() or exits
do_fork() Start point of fork
copy_process()
 Thread Implementation threads as same as standard processes One thread has own task_struct pid/ tgid Create clone() system call clone(CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND, 0); clone(SIGCHLD, 0); // fork() clone(CLONE_VFORK | CLONE_VM | SIGCHLD, 0); // vfork()
Kernel Threads Standard processes running in kernel space Do not have an address space(task_struct.mm is NULL) Schedulable, preemptable like normal process kthread_create() for creation
Process Termination exit() wait(), waitpid()
Scheduling
Scheduling CoopreativevsPreemptive  yield timeslice IO bound vs CPU bound Low latency vsHigh throughput
Process priority nice  Integer value(-20~19, default 0) High nice value correspond to low priority renice, setpriority() Realtime priority Always higher priority than normal processes Integer value(0~99)
Process priority Priority kernel internal Integer value (0~139) nice values[-20~19] are map to [100~139] [0~99] for realtime processes
Fairness scheduling RR on static timeslice 100ms(0 nice) vs 95ms(1 nice) 10ms(19 nice) vs 5ms (20 nice) A user’s 100 processes vs B user’s 1process Per user based scheduling Enable when kernel build Per thread level scheduling One nice value down gets 10% more CPU power vruntime(virtual clock) Support CGroupscheduling http://www.mjmwired.net/kernel/Documentation/scheduler/sched-design-CFS.txt
Overview schedule() Core T T T Ruequene do_fork() wake_up_new_task() T Tß T Waitqueue Core T Ruequene Core T T Ruequene Core T T Ruequene
tast_struct sched_class seched_entity sched_class Sched_entity load_weight on_rq vruntime rq load_weight cfs_rq rt_rq load_weight
CFS policy Soft real-time policy Posix standard Priority scheduling One nice level down gets 10% more CPU power Virtual clock Conceptual time considering priority Task waiting most of time will be scheduled to run Time order is managed by Runqueue
Data struct task_struct http://lxr.linux.no/linux+v2.6.39/include/linux/sched.h#L1193 SCHED_NORMAL SCHED_BATCH SCHED_IDLE SCHED_FIFO SCHED_RR
Data struct sched_class http://lxr.linux.no/linux+v2.6.39/include/linux/sched.h#L1056
Data struct rq http://lxr.linux.no/linux+v2.6.39/kernel/sched.c#L447
Data struct sched_entity http://lxr.linux.no/linux+v2.6.39/include/linux/sched.h#L1142
Dealing with priority Basic static_prio Value inherited by parent or set prio,normal_prio Dynamically changed
Dealing with priority Code
Computing Load weights load_weight
Remaining How to determine vruntime Process selection When schedule() function is called Context switching Sleep and Wake up Cgroup Hard to understand

Contenu connexe

Tendances

Perf stat windows
Perf stat windowsPerf stat windows
Perf stat windows
Accenture
 
USENIX ATC 2017 Performance Superpowers with Enhanced BPF
USENIX ATC 2017 Performance Superpowers with Enhanced BPFUSENIX ATC 2017 Performance Superpowers with Enhanced BPF
USENIX ATC 2017 Performance Superpowers with Enhanced BPF
Brendan Gregg
 
Tier 2 net app baseline design standard revised nov 2011
Tier 2 net app baseline design standard   revised nov 2011Tier 2 net app baseline design standard   revised nov 2011
Tier 2 net app baseline design standard revised nov 2011
Accenture
 
Process management in os
Process management in osProcess management in os
Process management in os
Miong Lazaro
 

Tendances (20)

systemd
systemdsystemd
systemd
 
Systemd for developers
Systemd for developersSystemd for developers
Systemd for developers
 
Process management in linux
Process management in linuxProcess management in linux
Process management in linux
 
Process and Threads in Linux - PPT
Process and Threads in Linux - PPTProcess and Threads in Linux - PPT
Process and Threads in Linux - PPT
 
Linux scheduler
Linux schedulerLinux scheduler
Linux scheduler
 
Introduction to systemd
Introduction to systemdIntroduction to systemd
Introduction to systemd
 
Basic of Systemd
Basic of SystemdBasic of Systemd
Basic of Systemd
 
Perf stat windows
Perf stat windowsPerf stat windows
Perf stat windows
 
LISA15: systemd, the Next-Generation Linux System Manager
LISA15: systemd, the Next-Generation Linux System Manager LISA15: systemd, the Next-Generation Linux System Manager
LISA15: systemd, the Next-Generation Linux System Manager
 
Linux kernel
Linux kernelLinux kernel
Linux kernel
 
USENIX ATC 2017 Performance Superpowers with Enhanced BPF
USENIX ATC 2017 Performance Superpowers with Enhanced BPFUSENIX ATC 2017 Performance Superpowers with Enhanced BPF
USENIX ATC 2017 Performance Superpowers with Enhanced BPF
 
Linux kernel debugging
Linux kernel debuggingLinux kernel debugging
Linux kernel debugging
 
Tier 2 net app baseline design standard revised nov 2011
Tier 2 net app baseline design standard   revised nov 2011Tier 2 net app baseline design standard   revised nov 2011
Tier 2 net app baseline design standard revised nov 2011
 
Linux System Monitoring basic commands
Linux System Monitoring basic commandsLinux System Monitoring basic commands
Linux System Monitoring basic commands
 
Systemd: the modern Linux init system you will learn to love
Systemd: the modern Linux init system you will learn to loveSystemd: the modern Linux init system you will learn to love
Systemd: the modern Linux init system you will learn to love
 
LSA2 - 02 Namespaces
LSA2 - 02  NamespacesLSA2 - 02  Namespaces
LSA2 - 02 Namespaces
 
The TCP/IP Stack in the Linux Kernel
The TCP/IP Stack in the Linux KernelThe TCP/IP Stack in the Linux Kernel
The TCP/IP Stack in the Linux Kernel
 
Linux kernel debugging
Linux kernel debuggingLinux kernel debugging
Linux kernel debugging
 
Linux monitoring
Linux monitoringLinux monitoring
Linux monitoring
 
Process management in os
Process management in osProcess management in os
Process management in os
 

En vedette

En vedette (10)

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

Similaire à Linux Process & CF scheduling

Profiling your Applications using the Linux Perf Tools
Profiling your Applications using the Linux Perf ToolsProfiling your Applications using the Linux Perf Tools
Profiling your Applications using the Linux Perf Tools
emBO_Conference
 
Track c-High speed transaction-based hw-sw coverification -eve
Track c-High speed transaction-based hw-sw coverification -eveTrack c-High speed transaction-based hw-sw coverification -eve
Track c-High speed transaction-based hw-sw coverification -eve
chiportal
 
Exploring Compiler Optimization Opportunities for the OpenMP 4.x Accelerator...
Exploring Compiler Optimization Opportunities for the OpenMP 4.x Accelerator...Exploring Compiler Optimization Opportunities for the OpenMP 4.x Accelerator...
Exploring Compiler Optimization Opportunities for the OpenMP 4.x Accelerator...
Akihiro Hayashi
 
Sedna XML Database: Executor Internals
Sedna XML Database: Executor InternalsSedna XML Database: Executor Internals
Sedna XML Database: Executor Internals
Ivan Shcheklein
 
Etude éducatif sur les GPUs & CPUs et les architectures paralleles -Programmi...
Etude éducatif sur les GPUs & CPUs et les architectures paralleles -Programmi...Etude éducatif sur les GPUs & CPUs et les architectures paralleles -Programmi...
Etude éducatif sur les GPUs & CPUs et les architectures paralleles -Programmi...
mouhouioui
 

Similaire à Linux Process & CF scheduling (20)

Trap Handling in Linux
Trap Handling in LinuxTrap Handling in Linux
Trap Handling in Linux
 
Process Address Space: The way to create virtual address (page table) of user...
Process Address Space: The way to create virtual address (page table) of user...Process Address Space: The way to create virtual address (page table) of user...
Process Address Space: The way to create virtual address (page table) of user...
 
Developing a Windows CE OAL.ppt
Developing a Windows CE OAL.pptDeveloping a Windows CE OAL.ppt
Developing a Windows CE OAL.ppt
 
Unix kernal
Unix kernalUnix kernal
Unix kernal
 
Profiling your Applications using the Linux Perf Tools
Profiling your Applications using the Linux Perf ToolsProfiling your Applications using the Linux Perf Tools
Profiling your Applications using the Linux Perf Tools
 
Intermediate Intel® Distribution of OpenVINO™ toolkit for Computer Vision Ap...
 Intermediate Intel® Distribution of OpenVINO™ toolkit for Computer Vision Ap... Intermediate Intel® Distribution of OpenVINO™ toolkit for Computer Vision Ap...
Intermediate Intel® Distribution of OpenVINO™ toolkit for Computer Vision Ap...
 
Monitoring with Prometheus
Monitoring with PrometheusMonitoring with Prometheus
Monitoring with Prometheus
 
Monitoring InfluxEnterprise
Monitoring InfluxEnterpriseMonitoring InfluxEnterprise
Monitoring InfluxEnterprise
 
Track c-High speed transaction-based hw-sw coverification -eve
Track c-High speed transaction-based hw-sw coverification -eveTrack c-High speed transaction-based hw-sw coverification -eve
Track c-High speed transaction-based hw-sw coverification -eve
 
計算機性能の限界点とその考え方
計算機性能の限界点とその考え方計算機性能の限界点とその考え方
計算機性能の限界点とその考え方
 
Containers: The What, Why, and How
Containers: The What, Why, and HowContainers: The What, Why, and How
Containers: The What, Why, and How
 
Exploring Compiler Optimization Opportunities for the OpenMP 4.x Accelerator...
Exploring Compiler Optimization Opportunities for the OpenMP 4.x Accelerator...Exploring Compiler Optimization Opportunities for the OpenMP 4.x Accelerator...
Exploring Compiler Optimization Opportunities for the OpenMP 4.x Accelerator...
 
Hardware & Software Platforms for HPC, AI and ML
Hardware & Software Platforms for HPC, AI and MLHardware & Software Platforms for HPC, AI and ML
Hardware & Software Platforms for HPC, AI and ML
 
Clojure ♥ cassandra
Clojure ♥ cassandra Clojure ♥ cassandra
Clojure ♥ cassandra
 
LINUX Device Drivers
LINUX Device DriversLINUX Device Drivers
LINUX Device Drivers
 
Interruption Timer Périodique
Interruption Timer PériodiqueInterruption Timer Périodique
Interruption Timer Périodique
 
Sedna XML Database: Executor Internals
Sedna XML Database: Executor InternalsSedna XML Database: Executor Internals
Sedna XML Database: Executor Internals
 
Etude éducatif sur les GPUs & CPUs et les architectures paralleles -Programmi...
Etude éducatif sur les GPUs & CPUs et les architectures paralleles -Programmi...Etude éducatif sur les GPUs & CPUs et les architectures paralleles -Programmi...
Etude éducatif sur les GPUs & CPUs et les architectures paralleles -Programmi...
 
Optimizing InfluxDB Performance in the Real World by Dean Sheehan, Senior Dir...
Optimizing InfluxDB Performance in the Real World by Dean Sheehan, Senior Dir...Optimizing InfluxDB Performance in the Real World by Dean Sheehan, Senior Dir...
Optimizing InfluxDB Performance in the Real World by Dean Sheehan, Senior Dir...
 
1032 cs208 g operation system ip camera case share.v0.2
1032 cs208 g operation system ip camera case share.v0.21032 cs208 g operation system ip camera case share.v0.2
1032 cs208 g operation system ip camera case share.v0.2
 

Dernier

Beautiful 😋 Call girls in Lahore 03210033448
Beautiful 😋 Call girls in Lahore 03210033448Beautiful 😋 Call girls in Lahore 03210033448
Beautiful 😋 Call girls in Lahore 03210033448
ont65320
 
Nayabad Call Girls ✔ 8005736733 ✔ Hot Model With Sexy Bhabi Ready For Sex At ...
Nayabad Call Girls ✔ 8005736733 ✔ Hot Model With Sexy Bhabi Ready For Sex At ...Nayabad Call Girls ✔ 8005736733 ✔ Hot Model With Sexy Bhabi Ready For Sex At ...
Nayabad Call Girls ✔ 8005736733 ✔ Hot Model With Sexy Bhabi Ready For Sex At ...
aamir
 
CHEAP Call Girls in Malviya Nagar, (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in  Malviya Nagar, (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in  Malviya Nagar, (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Malviya Nagar, (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Call Girls In Goa 9316020077 Goa Call Girl By Indian Call Girls Goa
Call Girls In Goa  9316020077 Goa  Call Girl By Indian Call Girls GoaCall Girls In Goa  9316020077 Goa  Call Girl By Indian Call Girls Goa
Call Girls In Goa 9316020077 Goa Call Girl By Indian Call Girls Goa
sexy call girls service in goa
 

Dernier (20)

Beautiful 😋 Call girls in Lahore 03210033448
Beautiful 😋 Call girls in Lahore 03210033448Beautiful 😋 Call girls in Lahore 03210033448
Beautiful 😋 Call girls in Lahore 03210033448
 
Almora call girls 📞 8617697112 At Low Cost Cash Payment Booking
Almora call girls 📞 8617697112 At Low Cost Cash Payment BookingAlmora call girls 📞 8617697112 At Low Cost Cash Payment Booking
Almora call girls 📞 8617697112 At Low Cost Cash Payment Booking
 
Nayabad Call Girls ✔ 8005736733 ✔ Hot Model With Sexy Bhabi Ready For Sex At ...
Nayabad Call Girls ✔ 8005736733 ✔ Hot Model With Sexy Bhabi Ready For Sex At ...Nayabad Call Girls ✔ 8005736733 ✔ Hot Model With Sexy Bhabi Ready For Sex At ...
Nayabad Call Girls ✔ 8005736733 ✔ Hot Model With Sexy Bhabi Ready For Sex At ...
 
Dakshineswar Call Girls ✔ 8005736733 ✔ Hot Model With Sexy Bhabi Ready For Se...
Dakshineswar Call Girls ✔ 8005736733 ✔ Hot Model With Sexy Bhabi Ready For Se...Dakshineswar Call Girls ✔ 8005736733 ✔ Hot Model With Sexy Bhabi Ready For Se...
Dakshineswar Call Girls ✔ 8005736733 ✔ Hot Model With Sexy Bhabi Ready For Se...
 
CHEAP Call Girls in Malviya Nagar, (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in  Malviya Nagar, (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in  Malviya Nagar, (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Malviya Nagar, (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Call Girls In Goa 9316020077 Goa Call Girl By Indian Call Girls Goa
Call Girls In Goa  9316020077 Goa  Call Girl By Indian Call Girls GoaCall Girls In Goa  9316020077 Goa  Call Girl By Indian Call Girls Goa
Call Girls In Goa 9316020077 Goa Call Girl By Indian Call Girls Goa
 
❤Personal Whatsapp Number Keylong Call Girls 8617697112 💦✅.
❤Personal Whatsapp Number Keylong Call Girls 8617697112 💦✅.❤Personal Whatsapp Number Keylong Call Girls 8617697112 💦✅.
❤Personal Whatsapp Number Keylong Call Girls 8617697112 💦✅.
 
VIP Model Call Girls Budhwar Peth ( Pune ) Call ON 8005736733 Starting From 5...
VIP Model Call Girls Budhwar Peth ( Pune ) Call ON 8005736733 Starting From 5...VIP Model Call Girls Budhwar Peth ( Pune ) Call ON 8005736733 Starting From 5...
VIP Model Call Girls Budhwar Peth ( Pune ) Call ON 8005736733 Starting From 5...
 
Model Call Girls In Pazhavanthangal WhatsApp Booking 7427069034 call girl ser...
Model Call Girls In Pazhavanthangal WhatsApp Booking 7427069034 call girl ser...Model Call Girls In Pazhavanthangal WhatsApp Booking 7427069034 call girl ser...
Model Call Girls In Pazhavanthangal WhatsApp Booking 7427069034 call girl ser...
 
Hotel And Home Service Available Kolkata Call Girls Howrah ✔ 6297143586 ✔Call...
Hotel And Home Service Available Kolkata Call Girls Howrah ✔ 6297143586 ✔Call...Hotel And Home Service Available Kolkata Call Girls Howrah ✔ 6297143586 ✔Call...
Hotel And Home Service Available Kolkata Call Girls Howrah ✔ 6297143586 ✔Call...
 
Top Rated Kolkata Call Girls Khardah ⟟ 6297143586 ⟟ Call Me For Genuine Sex S...
Top Rated Kolkata Call Girls Khardah ⟟ 6297143586 ⟟ Call Me For Genuine Sex S...Top Rated Kolkata Call Girls Khardah ⟟ 6297143586 ⟟ Call Me For Genuine Sex S...
Top Rated Kolkata Call Girls Khardah ⟟ 6297143586 ⟟ Call Me For Genuine Sex S...
 
Borum Call Girls Service ☎ ️93326-06886 ❤️‍🔥 Enjoy 24/7 Escort Service
Borum Call Girls Service ☎ ️93326-06886 ❤️‍🔥 Enjoy 24/7 Escort ServiceBorum Call Girls Service ☎ ️93326-06886 ❤️‍🔥 Enjoy 24/7 Escort Service
Borum Call Girls Service ☎ ️93326-06886 ❤️‍🔥 Enjoy 24/7 Escort Service
 
VIP Model Call Girls Koregaon Park ( Pune ) Call ON 8005736733 Starting From ...
VIP Model Call Girls Koregaon Park ( Pune ) Call ON 8005736733 Starting From ...VIP Model Call Girls Koregaon Park ( Pune ) Call ON 8005736733 Starting From ...
VIP Model Call Girls Koregaon Park ( Pune ) Call ON 8005736733 Starting From ...
 
Hotel And Home Service Available Kolkata Call Girls Sonagachi ✔ 6297143586 ✔C...
Hotel And Home Service Available Kolkata Call Girls Sonagachi ✔ 6297143586 ✔C...Hotel And Home Service Available Kolkata Call Girls Sonagachi ✔ 6297143586 ✔C...
Hotel And Home Service Available Kolkata Call Girls Sonagachi ✔ 6297143586 ✔C...
 
Model Call Girls In Ariyalur WhatsApp Booking 7427069034 call girl service 24...
Model Call Girls In Ariyalur WhatsApp Booking 7427069034 call girl service 24...Model Call Girls In Ariyalur WhatsApp Booking 7427069034 call girl service 24...
Model Call Girls In Ariyalur WhatsApp Booking 7427069034 call girl service 24...
 
Independent Garulia Escorts ✔ 9332606886✔ Full Night With Room Online Booking...
Independent Garulia Escorts ✔ 9332606886✔ Full Night With Room Online Booking...Independent Garulia Escorts ✔ 9332606886✔ Full Night With Room Online Booking...
Independent Garulia Escorts ✔ 9332606886✔ Full Night With Room Online Booking...
 
𓀤Call On 6297143586 𓀤 Ultadanga Call Girls In All Kolkata 24/7 Provide Call W...
𓀤Call On 6297143586 𓀤 Ultadanga Call Girls In All Kolkata 24/7 Provide Call W...𓀤Call On 6297143586 𓀤 Ultadanga Call Girls In All Kolkata 24/7 Provide Call W...
𓀤Call On 6297143586 𓀤 Ultadanga Call Girls In All Kolkata 24/7 Provide Call W...
 
Independent Sonagachi Escorts ✔ 9332606886✔ Full Night With Room Online Booki...
Independent Sonagachi Escorts ✔ 9332606886✔ Full Night With Room Online Booki...Independent Sonagachi Escorts ✔ 9332606886✔ Full Night With Room Online Booki...
Independent Sonagachi Escorts ✔ 9332606886✔ Full Night With Room Online Booki...
 
Independent Hatiara Escorts ✔ 9332606886✔ Full Night With Room Online Booking...
Independent Hatiara Escorts ✔ 9332606886✔ Full Night With Room Online Booking...Independent Hatiara Escorts ✔ 9332606886✔ Full Night With Room Online Booking...
Independent Hatiara Escorts ✔ 9332606886✔ Full Night With Room Online Booking...
 
📞 Contact Number 8617697112 VIP Ganderbal Call Girls
📞 Contact Number 8617697112 VIP Ganderbal Call Girls📞 Contact Number 8617697112 VIP Ganderbal Call Girls
📞 Contact Number 8617697112 VIP Ganderbal Call Girls
 

Linux Process & CF scheduling

  • 3. Process Program in the midst of execution How to create new process fork(), vfork() exec()
  • 4. Data structure task_struct Process descriptor http://lxr.linux.no/linux+v2.6.39/include/linux/sched.h#L1193 Priority(prio, static_prio, normal_prio) Scheduling class(sched_class) Scheduling policy(policy) Link parent, child, sibling, group_leader
  • 5. Data structure thread_infohttp://lxr.linux.no/linux+v2.6.39/arch/arm/include/asm/thread_info.h#L50 Describe process data accessed by architecture specific code Difference among other CPUs Managed information task_struct flags for scheduling(TIF_SIGPANDING, TIF_NEED_RESCHED) cpu number (for multi processor) preempt_count
  • 6. Data structure thread_unionhttp://lxr.linux.no/linux+v2.6.39/include/linux/sched.h#L2011 Kernel stack & thread_info 1 or 2 pages(8KB) Kernel stack size is less then 8K
  • 8. Process creation system call fork() Duplicate of the parent's page tables Create unique process descriptor for child(pidetc) Copy-on-Write Delay the copying pages exec() is called right after fork() vfork() Same as fork() except copying of parent page table Share parent's address space Child first scheme Parent is blocked until the child calls exec() or exits
  • 11. Thread Implementation threads as same as standard processes One thread has own task_struct pid/ tgid Create clone() system call clone(CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND, 0); clone(SIGCHLD, 0); // fork() clone(CLONE_VFORK | CLONE_VM | SIGCHLD, 0); // vfork()
  • 12. Kernel Threads Standard processes running in kernel space Do not have an address space(task_struct.mm is NULL) Schedulable, preemptable like normal process kthread_create() for creation
  • 13. Process Termination exit() wait(), waitpid()
  • 15. Scheduling CoopreativevsPreemptive yield timeslice IO bound vs CPU bound Low latency vsHigh throughput
  • 16. Process priority nice Integer value(-20~19, default 0) High nice value correspond to low priority renice, setpriority() Realtime priority Always higher priority than normal processes Integer value(0~99)
  • 17. Process priority Priority kernel internal Integer value (0~139) nice values[-20~19] are map to [100~139] [0~99] for realtime processes
  • 18. Fairness scheduling RR on static timeslice 100ms(0 nice) vs 95ms(1 nice) 10ms(19 nice) vs 5ms (20 nice) A user’s 100 processes vs B user’s 1process Per user based scheduling Enable when kernel build Per thread level scheduling One nice value down gets 10% more CPU power vruntime(virtual clock) Support CGroupscheduling http://www.mjmwired.net/kernel/Documentation/scheduler/sched-design-CFS.txt
  • 19. Overview schedule() Core T T T Ruequene do_fork() wake_up_new_task() T Tß T Waitqueue Core T Ruequene Core T T Ruequene Core T T Ruequene
  • 20. tast_struct sched_class seched_entity sched_class Sched_entity load_weight on_rq vruntime rq load_weight cfs_rq rt_rq load_weight
  • 21. CFS policy Soft real-time policy Posix standard Priority scheduling One nice level down gets 10% more CPU power Virtual clock Conceptual time considering priority Task waiting most of time will be scheduled to run Time order is managed by Runqueue
  • 22. Data struct task_struct http://lxr.linux.no/linux+v2.6.39/include/linux/sched.h#L1193 SCHED_NORMAL SCHED_BATCH SCHED_IDLE SCHED_FIFO SCHED_RR
  • 23. Data struct sched_class http://lxr.linux.no/linux+v2.6.39/include/linux/sched.h#L1056
  • 24. Data struct rq http://lxr.linux.no/linux+v2.6.39/kernel/sched.c#L447
  • 25. Data struct sched_entity http://lxr.linux.no/linux+v2.6.39/include/linux/sched.h#L1142
  • 26. Dealing with priority Basic static_prio Value inherited by parent or set prio,normal_prio Dynamically changed
  • 28. Computing Load weights load_weight
  • 29. Remaining How to determine vruntime Process selection When schedule() function is called Context switching Sleep and Wake up Cgroup Hard to understand

Notes de l'éditeur

  1. wake_up_new_task; in other words, the task structure is added to the scheduler queue뒤쪽에서 스케줄링에서 설명하겠지만 생성된 프로세스는 무조건 한번은 수행되도록 보장함
  2. Check flag – for clone system call parameterDup_task_struct – 실제 복사가 이루어짐Sched_fork – 스케줄링에 관련된 내용이 복사됨(확인요함)
  3. Vruntime – 실제 수행된 시간에 prority별로 가중치를 둔 이후, 가장 수행시간이 적은 task 위주로 수행함
  4. Prio, normal_proi – 동적으로 변함Static_proi- 고정됨Rt_prioroty – realtime인 경우만설정, 그렇지 않은 경우 0,max 99Sched_entity를 갖는 것은 모든지 스케줄링이 될 수 있음Policy는 cpu에 동작할 때의 정책 –sched_normalCpus_allows – bitfield로 특정 cpu에서 동작하는 것을 제한Tile_slice for realtimeß
  5. Nr_running – 현재 큐에 들어있는 태스크 갯수Load – 가중치를 고려한 테스크의 워크로드Clock은 해당 런큐가 주기적으로 스케줄링을 받도록 계산하기 위하여 사용됨Cpu_load는 이전의 워크로드를 기록 – 로드벨런싱, 그룹핑에 쓰임\\
  6. 전체 큐의 워크로드런큐 내부적으로 rb를 이용하기 때문에, 그에 필요한 노드On_rq – 현재 스케줄링이 되고 있는지 확인CFS를 구현하기 위하여 필요한 시간 값Task_struct가 sched_entity를 가지고 있기 때문에 스케줄링을 받을 수 있음
  7. 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)에 나눗셈을 미리 계산해 둔 값이다.