More Related Content Similar to スケジューラからみたOSの話 (20) More from Takeshi Fujiwara (6) スケジューラからみたOSの話1. OS
2009.06.22
warawara@bug.co.jp
2. kernel
OS Windows XP NT kernel
MacOS X mach
CPU kernel CPU
Process Thread Task
7. MB CPU
CPU
CPU
Cache, MMU, NUMA, Xen
Core
Core
Core
Core
HT
HT
32. preemptive multitask
Windows
95/98/Me
Windows 9x
Windows NT3.x/
4.0/2000/Xp/Vista/7 Windows NT
MacOS X(mach)
SVR4, 4.4BSD, ...
UNIX/Linux VxWorks, QNX,
ThreadX, ...
RTOS
...
45. ! ! ! !
! ! ! ! !
! ! ! ! ! !
! ! ! ! ! !
46. ! ! ! !
! ! ! ! !
! ! ! ! ! !
! ! ! ! ! !
48. FIFO
Task D Task D
Task C Round Robin
Task C
Task B Task B
Task A Task A
51. I/O
I/O
(nice )
I/O (
)
CPU
69. vs
Kernel User
MacOS X, BeOS, NeXTstep, ...
72. (RTOS )
(Linux 2.2 )
IRQ (Linux 2.4, WindowsNT )
(Linux 2.6)
76. (RTOS )
IRQ
CPU
(Linux 2.2 )
IRQ ...
IRQ (Linux 2.4, WindowsNT )
(Linux 2.6)
86. WindowsNT
Windows9x 1tick=20msec
1tick=20msec
Ready Queue(0 31)
87. WindowsNT
1tick=20msec
Ready
0 31(
(0
)
31)
0 15
16 31
(-2 +2)
REALTIME_PRIORITY_CLASS 24
HIGH_PRIORITY_CLASS 13
NORMAL_PRIORITY_CLASS 7(background) or 9(foreground)
IDLE_PRIORITY_CLASS 4
88. WindowsNT
1tick=20msec
Ready Queue(0 31)
0 15
foreground (background )
( 1 )
90. SVR4
Ready (0 160)
preemptive
(mutex, )
91. SVR4
Ready (0 160)
preemptive
(mutex, )
92. SVR4
Ready (0 160)
Round Robin
preemptive
(mutex, )
93. SVR4
Ready
0 159( (0 ) 160)
0 59
60 99
preemptive
100 159
※
(mutex, )
94. SVR4
Ready (0 160)
preemptive
→
→
(mutex,
→
)
95. SVR4
Ready (0 160)
preemptive
(mutex, )
96. SVR4
Ready (0 160)
CPU
preemptive
(mutex, )
98. Solaris2.6
SVR4
1tick=10msec( )
CPU Dispatch Queue
LWP
Preemptive
99. Solaris2.6
1tick=10msec( )
0 169( ) 0 169( )
60 99
CPU
SYS(System)
Dispatch Queue
0 59 TS(Time Share) , IA(Interactive)
100 159 RT(Realtime)
160 169
LWP
Preemptive
102. NORTi(μITRON4)
1tick=10msec(NORTi)
(RealTime )
Ready
FIFO
(mutex)
103. NORTi(μITRON4)
1tick=10msec(NORTi)
(RealTime )
Ready
FIFO
(mutex)
104. NORTi(μITRON4)
1tick=10msec(NORTi)
(RealTime )
1 Ready
31( )
※
FIFO
OS (mutex)
105. NORTi(μITRON4)
1tick=10msec(NORTi)
(RealTime )
Ready
FIFO
FIFO
(mutex)
Round Robin Ready Queue
107. Linux 2.4
1tick=10msec( )
1 99( )
Ready Queue
200msec
SCHED_FIFO
SCHED_RR Round Robin
SCHED_OTHER 4.3BSD
CPU
108. Linux 2.4
1 Ready Queue (goodness)
CPU 1
1tick=10msec( ) goodness = 0
(1~99) goodness = 1000 +
goodness =
goodness 0
→ Ready Queue
CPU
111. Linux 2.6
1tick=1msec( )
v2.6.13 4msec
BeOS 3msec
,CPU Ready Queue
Preemptive
Kernel CPU
Active Queue Expire Queue
112. Linux 2.6
SCHED_FIFO
1tick=1msec( )
,CPU1 139(
Ready Queue
)
1 99
Preemptive 100 139
Kernel CPU
Active Queue Expire Queue
113. Linux 2.6
SCHED_FIFO
1tick=1msec( )
SCHED_RR Round Robin
,CPU Ready Queue (msec)
0~99 5
SCHED_OTHER 4.3BSD 100~199 4
SCHED_BAT
Preemptive 200~299 3
300~399 2
Kernel CPU 400~499 1
500~599 0
Active Queue Expire Queue 600~699 -1
...
900~999 -4
1sec -5
114. Linux 2.6
Bonus
800 139
(msec)
( ) Bonus=0
600 Bonus=10
126
400
113
200
0 100
100 113 126 139 100 113 126 139
Bonus
Bonus
1
Bonus=0
Bonus=2
Bonus=5
Bonus=10
Bonus
0
100 113 126 139
115. Linux 2.6
O(1)
Active Queue Expire Queue
100 Task A Task B Task C 100
101 Task D 101
102 Task E 102
103 103
...
...
138 Task F 138
139 139
CPU
116. Linux 2.6
O(1)
Active Queue Expire Queue
100 Task B Task C 100 Task A
101 Task D 101
102 Task E 102
103 103
...
...
138 Task F 138
139 139
CPU
117. Linux 2.6
O(1)
Active Queue Expire Queue
100 100 Task A Task B Task C
101 101 Task D
102 102 Task E
103 103
...
...
138 138 Task F
139 139
118. Linux 2.6
O(1)
Expire Queue Active Queue
100 100 Task A Task B Task C
101 101 Task D
102 102 Task E
103 103
...
...
138 138 Task F
139 139
123. Xen
bvt (borrowed virtual time)
MB
MB
MB
CPU
sedf(Simple Early Deadline First)
CPU
CPU
CPU
CPU
CPU
credit
Core
Core
Core
Core
Core
Core
Core
Core
Core
Core
Core
Core
HT
HT
HT
HT
HT
HT
124. Xen
bvt (borrowed virtual time)
MB
MB
MB
CPU
sedf(Simple Early Deadline First)
CPU
CPU v3.0.2
CPU
CPU
CPU
credit
Core
Core
Core
Core
Core
Core
Core
Core
Core
Core
Core
Core
HT
HT
HT
HT
HT
HT
125. Xen
bvt (borrowed virtual time)
MB
MB
MB
CPU
sedf(Simple Early Deadline First)
CPU
CPU
CPU
CPU
CPU
credit
Core
Core
Core
Core
Core
Core
Core
Core
Core
Core CPU Deadline
Core
Core
Runnable Queue Wait Queue CPU
HT
HT
HT
HT bvt sedf SMP =CPU
HT
HT
126. Xen
bvt (borrowed virtual time)
MB
MB
MB
CPU
sedf(Simple Early Deadline First)
CPU
CPU
CPU
CPU
CPU
credit
Core
Core
Core
Core
Core
Core
Core
Core
Core
Core
Core
Core
CPU Run Queue Run Queue
HT
HT credit credit CPU
HT
HT
HT
HT CPU credit UNDER credit OVER
UNDER
credit 10msec credit 0
weight
129. I/O
I/O Queue
Queue 4
Linux2.6
130. I/O
No Operation
Queue
131. I/O
Complete Fairness Queueing
ID 64
Round Robin
132. I/O
Deadline
4 Queue Queue Deadline Queue / Queue
Deadline Queue
Queue
500msec
5sec
133. I/O
Anticipatory
125msec 250msec
I/O
7msec