スケジューラからみたOSの話

2,669
-1

Published on

2009新人ゼミ資料。
スケジューラを切り口とした各種OSの話。広く浅く。

Published in: Technology
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,669
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
24
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

スケジューラからみたOSの話

  1. 1. OS 2009.06.22 warawara@bug.co.jp
  2. 2. kernel OS Windows XP NT kernel MacOS X mach CPU kernel CPU Process Thread Task
  3. 3. OS OS
  4. 4. OS OS
  5. 5. CPU CPU
  6. 6. CPU CPU
  7. 7. MB CPU CPU CPU Cache, MMU, NUMA, Xen Core Core Core Core HT HT
  8. 8. MS-DOS OS
  9. 9. Task A Task B Task B
  10. 10. Windows 3.1 System7.0, MacOS8~9 PalmOS Protothreads μITRON
  11. 11. non-preemptive Windows 1.0/2.x/3.x Windows 3.1 System7.0, MacOS8~9 PalmOS Switch-case Protothreads μITRON
  12. 12. Task A Task B Task B
  13. 13. Thread Manager(System7.5 )
  14. 14. Thread Manager(System7.5 ) Preemptive
  15. 15. Windows 9x Windows NT MacOS X(mach) UNIX/Linux RTOS ...
  16. 16. 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 ...
  17. 17. ... ...
  18. 18. ! ! ! !
  19. 19. ! ! ! !
  20. 20. ! ! ! ! ! ! !
  21. 21. ! ! ! ! ! ! !
  22. 22. ! ! ! ! ! ! ! ! ! !
  23. 23. ! ! ! ! ! ! ! ! ! !
  24. 24. ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !
  25. 25. ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !
  26. 26. FIFO Round Robin
  27. 27. FIFO Task D Task D Task C Round Robin Task C Task B Task B Task A Task A
  28. 28. I/O (nice )
  29. 29. I/O I/O (nice ) I/O ( ) CPU
  30. 30. Sem
  31. 31. Sem Sem
  32. 32. Sem Sem Sem
  33. 33. Sem Sem Sem
  34. 34. Sem VxWorks (1997) Sem Sem
  35. 35. Non-preemptive kernel Preemptive kernel Preemptive kernel
  36. 36. Non-preemptive kernel
  37. 37. Preemptive kernel
  38. 38. Preemptive kernel SVR4
  39. 39. vs
  40. 40. I/O vs ...
  41. 41. Ready Queue vs CPU Ready Queue
  42. 42. vs Kernel User MacOS X, BeOS, NeXTstep, ...
  43. 43. (RTOS , Solaris) (Linux 2.2 ) IRQ (Linux 2.4, WindowsNT ) (Linux 2.6)
  44. 44. (RTOS ) (Linux 2.2 ) IRQ (Linux 2.4, WindowsNT ) (Linux 2.6)
  45. 45. (RTOS , Solaris) (Linux 2.2 ) IRQ (Linux 2.4, WindowsNT ) (Linux 2.6)
  46. 46. (RTOS , Solaris) (Linux 2.2 ) IRQ (Linux 2.4, WindowsNT ) (Linux 2.6)
  47. 47. (RTOS ) Linux2.4/Windows NT IRQ ( CPU ) (Linux 2.2 ) IRQ (Linux 2.4, WindowsNT ) (Linux 2.6)
  48. 48. (RTOS ) IRQ CPU (Linux 2.2 ) IRQ ... IRQ (Linux 2.4, WindowsNT ) (Linux 2.6)
  49. 49. 4.3BSD(SVR3) 1tick=10msec( ) ( ) =32 ( ) 4tick 100tick(1sec) I/O Ready
  50. 50. 4.3BSD(SVR3) 1tick=10msec( ) ( ) =32 4tick 100tick(1sec) I/O Ready
  51. 51. 4.3BSD(SVR3) 1tick=10msec( ) ( ) =32 0 127( ) 0 49 Kernel (Sleep ) 4tick 50 127 100tick(1sec) I/O Ready
  52. 52. 4.3BSD(SVR3) 1tick=10msec( ) ( ) =32 CPU (tick ) 4tick (SVR3=0.5) 4.3BSD 100tick(1sec) I/O Ready
  53. 53. 4.3BSD(SVR3) 1tick=10msec( ) ( ) =32 4tick Ready Queue 32 Queue 100tick(1sec)100msec (4.3BSD) Round Robin I/O Ready
  54. 54. 4.3BSD(SVR3) 1tick=10msec( ) ( ) =32 1 4tick 100tick(1sec) I/O Ready
  55. 55. WindowsNT 1tick=20msec Ready Queue(0 31)
  56. 56. WindowsNT Windows9x 1tick=20msec 1tick=20msec Ready Queue(0 31)
  57. 57. 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
  58. 58. WindowsNT 1tick=20msec Ready Queue(0 31) 0 15 foreground (background ) ( 1 )
  59. 59. WindowsNT 1tick=20msec Ready Queue(0 31) CPU( ) ( )
  60. 60. SVR4 Ready (0 160) preemptive (mutex, )
  61. 61. SVR4 Ready (0 160) preemptive (mutex, )
  62. 62. SVR4 Ready (0 160) Round Robin preemptive (mutex, )
  63. 63. SVR4 Ready 0 159( (0 ) 160) 0 59 60 99 preemptive 100 159 ※ (mutex, )
  64. 64. SVR4 Ready (0 160) preemptive → → (mutex, → )
  65. 65. SVR4 Ready (0 160) preemptive (mutex, )
  66. 66. SVR4 Ready (0 160) CPU preemptive (mutex, )
  67. 67. Solaris2.6 1tick=10msec( ) CPU Dispatch Queue LWP Preemptive
  68. 68. Solaris2.6 SVR4 1tick=10msec( ) CPU Dispatch Queue LWP Preemptive
  69. 69. 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
  70. 70. Solaris2.6 1tick=10msec( ) LWP(Light Weight Process) CPU Dispatch Queue LWP Preemptive
  71. 71. Solaris2.6 1tick=10msec( ) Non-preemption CPU Dispatch Queue thread_create() pause_cpus() LWP HAT, MMU Preemptive
  72. 72. NORTi(μITRON4) 1tick=10msec(NORTi) (RealTime ) Ready FIFO (mutex)
  73. 73. NORTi(μITRON4) 1tick=10msec(NORTi) (RealTime ) Ready FIFO (mutex)
  74. 74. NORTi(μITRON4) 1tick=10msec(NORTi) (RealTime ) 1 Ready 31( ) ※ FIFO OS (mutex)
  75. 75. NORTi(μITRON4) 1tick=10msec(NORTi) (RealTime ) Ready FIFO FIFO (mutex) Round Robin Ready Queue
  76. 76. Linux 2.4 1tick=10msec( ) Ready Queue CPU
  77. 77. Linux 2.4 1tick=10msec( ) 1 99( ) Ready Queue 200msec SCHED_FIFO SCHED_RR Round Robin SCHED_OTHER 4.3BSD CPU
  78. 78. Linux 2.4 1 Ready Queue (goodness) CPU 1 1tick=10msec( ) goodness = 0 (1~99) goodness = 1000 + goodness = goodness 0 → Ready Queue CPU
  79. 79. Linux 2.4 1tick=10msec( ) Ready Queue I/O I/O DB CPU CPU Non-preemptive
  80. 80. Linux 2.6 1tick=1msec( ) ,CPU Ready Queue Preemptive Kernel CPU Active Queue Expire Queue
  81. 81. Linux 2.6 1tick=1msec( ) v2.6.13 4msec BeOS 3msec ,CPU Ready Queue Preemptive Kernel CPU Active Queue Expire Queue
  82. 82. Linux 2.6 SCHED_FIFO 1tick=1msec( ) ,CPU1 139( Ready Queue ) 1 99 Preemptive 100 139 Kernel CPU Active Queue Expire Queue
  83. 83. 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
  84. 84. 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
  85. 85. 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
  86. 86. 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
  87. 87. 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
  88. 88. 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
  89. 89. Linux 2.6.23 CFS(Completely Fair Scheduler) Queue Queue Tree
  90. 90. Linux 2.6.23 CFS(Completely Fair Scheduler) CPU CPU Queue Queue Tree
  91. 91. Linux 2.6.23 CFS(Completely Fair Scheduler) Queue Queue Tree
  92. 92. Linux 2.6.23 CFS(Completely Fair Scheduler) Queue Queue Tree
  93. 93. 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
  94. 94. 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
  95. 95. 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
  96. 96. 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
  97. 97. I/O
  98. 98. I/O I/O Queue Queue 4 Linux2.6
  99. 99. I/O No Operation Queue
  100. 100. I/O Complete Fairness Queueing ID 64 Round Robin
  101. 101. I/O Deadline 4 Queue Queue Deadline Queue / Queue Deadline Queue Queue 500msec 5sec
  102. 102. I/O Anticipatory 125msec 250msec I/O 7msec
  103. 103. Q&A
  104. 104. Fin.

×