cpu.html 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1">
  6. <title>CPU &amp; Scheduling | NebOS Architecture</title>
  7. <meta name="description" content="NebOS CPU architecture: GDT/TSS, PIC/PIT and LAPIC interrupts, IOAPIC masking, ACPI SMP bring-up, CFS-lite scheduling, wait queues, the big kernel lock, idle, power and AMD/Intel thermal management.">
  8. <link rel="icon" href="favicon.svg" type="image/svg+xml">
  9. <link rel="stylesheet" href="style.css">
  10. </head>
  11. <body>
  12. <a class="skip" href="#main">Skip to content</a>
  13. <header class="site-header">
  14. <a class="brand" href="index.html">
  15. <span class="brand-mark" aria-hidden="true"></span>
  16. <span>NebOS <span class="brand-sub">Architecture</span></span>
  17. </a>
  18. <nav class="site-nav" aria-label="Architecture sections">
  19. <a href="index.html">Overview</a>
  20. <a href="boot.html">Boot</a>
  21. <a href="memory.html">Memory</a>
  22. <a href="cpu.html" aria-current="page">CPU</a>
  23. <a href="drivers.html">Drivers</a>
  24. <a href="filesystems.html">Filesystems</a>
  25. <a href="graphics.html">Graphics</a>
  26. <a href="network.html">Network</a>
  27. <a href="userland.html">Userland</a>
  28. <a href="development.html">Development</a>
  29. </nav>
  30. </header>
  31. <main id="main" class="page">
  32. <div class="page-head">
  33. <p class="kicker">CPU &amp; scheduling</p>
  34. <h1>Weighted fairness, one global run queue, one big lock.</h1>
  35. <p class="lede">
  36. NebOS runs a CFS-lite scheduler over a single global run queue and
  37. per-CPU <code>current</code> pointers. ACPI/MADT brings up the APs,
  38. each CPU has its own GDT, TSS and timer, and a sleeping recursive
  39. mutex — the big kernel lock — serializes kernel execution.
  40. </p>
  41. <div class="meta">
  42. <span class="pill">8 CPUs max</span>
  43. <span class="pill">64 process slots</span>
  44. <span class="pill">10 ms slice</span>
  45. <span class="pill">1 kHz busy / 100 Hz idle</span>
  46. </div>
  47. </div>
  48. <nav class="toc" aria-label="On this page">
  49. <h2>On this page</h2>
  50. <ul>
  51. <li><a href="#bringup">Boot CPU bring-up</a></li>
  52. <li><a href="#interrupts">Interrupts &amp; timers</a></li>
  53. <li><a href="#smp">SMP bring-up</a></li>
  54. <li><a href="#process">Process model</a></li>
  55. <li><a href="#scheduler">CFS-lite scheduler</a></li>
  56. <li><a href="#bkl">Big kernel lock</a></li>
  57. <li><a href="#idle">Idle &amp; power</a></li>
  58. <li><a href="#sources">Source map</a></li>
  59. </ul>
  60. </nav>
  61. <section id="bringup">
  62. <h2>Boot CPU bring-up</h2>
  63. <p>
  64. After <code>kernel_main</code> clears BSS and starts the boot console,
  65. the first structural step is <code>gdt_tss_init(0)</code>. The GDT/TSS
  66. and the per-CPU GS base must exist before any code that calls
  67. <code>current_proc()</code> or <code>this_cpu()</code>.
  68. </p>
  69. <ul>
  70. <li>Each CPU has a <code>struct cpu</code> holding <code>current</code>, <code>idle</code>, its TSS, LAPIC id, tick period and scheduling flags.</li>
  71. <li><code>%gs:0</code> points at the current CPU's <code>current</code> field; <span class="file">switch.S</span> reads it directly. A static assert locks the offsets.</li>
  72. <li>The TSS <code>esp0</code> is updated by <code>schedule()</code>, so ring-3 entry always lands on the process's kernel stack.</li>
  73. <li><code>process_init()</code> must run before <code>timer_init()</code>: once the PIT starts, the timer stub can switch context on every tick.</li>
  74. </ul>
  75. </section>
  76. <section id="interrupts">
  77. <h2>Interrupts &amp; timers</h2>
  78. <p>
  79. The BSP keeps the legacy 8259 PIC and PIT; there is no IOAPIC
  80. driver. After ACPI init the kernel masks every normal IOAPIC
  81. redirection entry (leaving ExtINT entries alone, in case the 8259
  82. is routed through an IOAPIC pin), so firmware-left vectors cannot
  83. collide with the PIC vectors or the LAPIC timer. APs mask their
  84. LINT0/LINT1 inputs and use only their local APIC timer and IPIs.
  85. </p>
  86. <div class="table-wrap">
  87. <table>
  88. <thead>
  89. <tr><th>Source</th><th>Vector</th><th>Role</th></tr>
  90. </thead>
  91. <tbody>
  92. <tr><td>8259 PIC + PIT</td><td>IRQ0, etc.</td><td>BSP global clock and device interrupts; PIT tick advances the millisecond clock.</td></tr>
  93. <tr><td>LAPIC timer</td><td><code>0x30</code></td><td>Per-AP scheduling tick; 1 ms busy, 10 ms idle.</td></tr>
  94. <tr><td>LAPIC IPI</td><td><code>0x31</code></td><td>Reschedule request; must be EOIed on the target LAPIC.</td></tr>
  95. <tr><td><code>int 0x80</code></td><td>syscall gate</td><td>Ring-3 service entry.</td></tr>
  96. <tr><td><code>int 0x81</code></td><td>voluntary yield</td><td>Blocking helpers and <code>schedule()</code>.</td></tr>
  97. </tbody>
  98. </table>
  99. </div>
  100. <p>
  101. The timer period is not fixed. While a process runs, the BSP PIT ticks
  102. at 1 kHz and AP LAPIC timers tick every 1 ms. While a CPU is idle, the
  103. BSP drops to 100 Hz and APs to 10 ms so MWAIT/HLT can hold a deeper
  104. state. The global millisecond clock remains accurate because the PIT
  105. stub advances it by the current tick period.
  106. </p>
  107. <figure class="figure">
  108. <div class="bars" role="img" aria-label="Timer rates: 1000 Hz while busy, 100 Hz while idle. Bar widths are relative to 1000 Hz.">
  109. <div class="bar-row">
  110. <span class="bar-label">BSP busy</span>
  111. <div class="bar-track"><span class="bar-fill green" style="--w:100%"></span></div>
  112. <span class="bar-value">1000 Hz</span>
  113. </div>
  114. <div class="bar-row">
  115. <span class="bar-label">BSP idle</span>
  116. <div class="bar-track"><span class="bar-fill" style="--w:10%"></span></div>
  117. <span class="bar-value">100 Hz</span>
  118. </div>
  119. <div class="bar-row">
  120. <span class="bar-label">AP busy</span>
  121. <div class="bar-track"><span class="bar-fill green" style="--w:100%"></span></div>
  122. <span class="bar-value">1 ms</span>
  123. </div>
  124. <div class="bar-row">
  125. <span class="bar-label">AP idle</span>
  126. <div class="bar-track"><span class="bar-fill" style="--w:10%"></span></div>
  127. <span class="bar-value">10 ms</span>
  128. </div>
  129. </div>
  130. <figcaption>
  131. <strong>Race to idle, then stay there.</strong> When a wake-up
  132. arrives, <code>smp_resched_wake()</code> shortens the idle period so
  133. the woken process runs at the next millisecond instead of waiting
  134. out a 10 ms nap.
  135. </figcaption>
  136. </figure>
  137. </section>
  138. <section id="smp">
  139. <h2>SMP bring-up</h2>
  140. <p>
  141. SMP is ACPI-only: RSDP → RSDT/XSDT → MADT → CPU/LAPIC list. There is
  142. deliberately no Intel MP-table parser. A machine without ACPI, a
  143. usable MADT, the CPUID APIC bit or a LAPIC stays uniprocessor and
  144. follows exactly the old 8259/PIT path.
  145. </p>
  146. <p>
  147. The same table walk reads the FADT's <code>century</code> byte (offset
  148. 108) and exposes the CMOS register to <span class="file">rtc.c</span>,
  149. which writes it when setting the clock so the two-digit year stays in
  150. the intended century. Boards without ACPI get no century write and
  151. keep the 1970–2069 read window.
  152. </p>
  153. <ol>
  154. <li>Copy the AP trampoline to <code>0x6000</code> (SIPI vector <code>0x06</code>).</li>
  155. <li>Allocate an AP idle PCB and kernel stack via <code>process_init_ap()</code>.</li>
  156. <li>Fill the startup block at <code>0x6F00</code> with CR3, stack top, C entry and CPU index.</li>
  157. <li>Send INIT, then SIPI-SIPI, with a second SIPI retry.</li>
  158. <li>The trampoline clears <code>CR0.CD</code>/<code>CR0.NW</code>: INIT leaves an AP with caching disabled (<code>CR0 = 0x60000010</code>), and before this every ring-3 process on an AP ran about 100× slower on real hardware (QEMU does not model caches). The wake-up value is written back to <code>0x6F10</code> and logged as <code>smp: AP n start cr0 …</code>.</li>
  159. <li>The AP enters <code>smp_ap_main</code>, initialises its LAPIC timer and idle loop, and waits.</li>
  160. <li>After device/FS setup, <code>smp_enable_sched()</code> lets APs take user work.</li>
  161. </ol>
  162. <p>
  163. Kernel threads stay pinned to the BSP; only ring-3 processes may run
  164. on an AP. Each AP runs <code>cpu_enable_sse()</code> because it starts
  165. with firmware <code>CR4</code>; without OSFXSR/OSXMMEXCPT the SSE2
  166. drawing fast paths would <code>#UD</code>. Every CPU also runs
  167. <code>cpu_init_fpu()</code> (<code>CR0.NE</code>/<code>MP</code>,
  168. <code>FNINIT</code>): an AP leaves INIT with <code>CR0.NE</code> clear
  169. and an x87 control word of <code>0x0040</code>, so every inexact
  170. floating-point result froze it until the next timer tick, and the
  171. browser's JavaScript ran hundreds of times slower on an AP. Each
  172. process owns its x87 state; <code>schedule()</code> saves it with
  173. <code>FNSAVE</code> and restores it with <code>FRSTOR</code> on every
  174. switch (108 bytes in <code>struct process</code>, no FXSR needed).
  175. </p>
  176. <div class="warn">
  177. <p><strong>No IOAPIC driver.</strong> Device IRQs never reach an AP,
  178. and <code>pit_irq_stub</code> is BSP-only. The kernel masks the
  179. IOAPIC's normal redirection entries after ACPI init
  180. (<span class="file">ioapic.c</span>) and keeps the 8259 path on
  181. LAPIC LINT0; ExtINT entries survive so firmware that routes the
  182. 8259 through an IOAPIC pin still works.</p>
  183. </div>
  184. </section>
  185. <section id="process">
  186. <h2>Process model</h2>
  187. <p>
  188. Every process is a stable heap-allocated PCB referenced from a sparse
  189. <code>procs[64]</code> table, so a process pointer never moves when
  190. another slot changes. The idle context is not a process slot: the
  191. <code>kernel_main</code> context becomes the BSP idle state, and APs
  192. have their own idle PCBs.
  193. </p>
  194. <ul>
  195. <li><strong>Kernel threads</strong> are created with <code>process_create</code> and take the BKL automatically.</li>
  196. <li><strong>Ring-3 processes</strong> are created from an ELF image with their own page directory, 32-page (128 KB) user stack and cwd.</li>
  197. <li><strong>The kworker</strong> is an ordinary kernel process that performs housekeeping and zombie reaping, so it cannot be starved by a busy system.</li>
  198. <li><strong>Stable naming:</strong> process names are 12 bytes; the PCB holds the TTY id, cwd, affinity mask, CPU accounting and the scheduling entity.</li>
  199. </ul>
  200. <figure class="figure">
  201. <svg viewBox="0 0 920 260" role="img" aria-labelledby="states-title states-desc">
  202. <title id="states-title">Process state transitions</title>
  203. <desc id="states-desc">Processes move between ready, running, sleeping, blocked and dead states. Wake-ups return to ready, and exit or kill moves to dead.</desc>
  204. <rect class="svg-box green" x="48" y="96" width="150" height="58" rx="9"/>
  205. <text class="svg-text" x="123" y="120" text-anchor="middle">READY</text>
  206. <text class="svg-sub" x="123" y="140" text-anchor="middle">run queue</text>
  207. <rect class="svg-box accent" x="288" y="96" width="150" height="58" rx="9"/>
  208. <text class="svg-text" x="363" y="120" text-anchor="middle">RUNNING</text>
  209. <text class="svg-sub" x="363" y="140" text-anchor="middle">one per CPU</text>
  210. <rect class="svg-box blue" x="528" y="28" width="150" height="58" rx="9"/>
  211. <text class="svg-text" x="603" y="52" text-anchor="middle">SLEEPING</text>
  212. <text class="svg-sub" x="603" y="72" text-anchor="middle">deadline in sleep list</text>
  213. <rect class="svg-box blue" x="528" y="164" width="150" height="58" rx="9"/>
  214. <text class="svg-text" x="603" y="188" text-anchor="middle">BLOCKED</text>
  215. <text class="svg-sub" x="603" y="208" text-anchor="middle">wait queue</text>
  216. <rect class="svg-box amber" x="756" y="96" width="136" height="58" rx="9"/>
  217. <text class="svg-text" x="824" y="120" text-anchor="middle">DEAD</text>
  218. <text class="svg-sub" x="824" y="140" text-anchor="middle">zombie queue</text>
  219. <path class="svg-line green" d="M198 118h84"/>
  220. <path class="svg-line green" d="M276 112l7 6-7 6"/>
  221. <text class="svg-tiny" x="240" y="108" text-anchor="middle">pick</text>
  222. <path class="svg-line" d="M363 154v28H198v-24"/>
  223. <path class="svg-line" d="M192 162l6-7 6 7"/>
  224. <text class="svg-tiny" x="300" y="196" text-anchor="middle">slice / yield</text>
  225. <path class="svg-line blue" d="M438 112h84"/>
  226. <path class="svg-line blue" d="M516 106l7 6-7 6"/>
  227. <text class="svg-tiny" x="480" y="103" text-anchor="middle">sleep</text>
  228. <path class="svg-line blue" d="M438 138v46h84"/>
  229. <path class="svg-line blue" d="M516 178l7 6-7 6"/>
  230. <text class="svg-tiny" x="480" y="176" text-anchor="middle">wait</text>
  231. <path class="svg-line" d="M603 86V62h-240v34"/>
  232. <path class="svg-line" d="M357 90l6-7 6 7"/>
  233. <text class="svg-tiny" x="475" y="56" text-anchor="middle">wake</text>
  234. <path class="svg-line" d="M603 222v18H363v-18"/>
  235. <path class="svg-line" d="M357 228l6-7 6 7"/>
  236. <text class="svg-tiny" x="478" y="248" text-anchor="middle">wake</text>
  237. <path class="svg-line amber" d="M438 125h312"/>
  238. <path class="svg-line amber" d="M744 119l7 6-7 6"/>
  239. <text class="svg-tiny" x="594" y="119" text-anchor="middle">exit / kill</text>
  240. </svg>
  241. <figcaption>
  242. <strong>Five states, two queues.</strong> The run queue is global;
  243. the sleep list is sorted by deadline; wait queues are per-object.
  244. A woken process is clamped to the current minimum vruntime so an
  245. interactive wake-up is scheduled promptly without accumulating
  246. unbounded credit.
  247. </figcaption>
  248. </figure>
  249. </section>
  250. <section id="scheduler">
  251. <h2>CFS-lite scheduler</h2>
  252. <p>
  253. Weight is an integer from 1 to 16. Each ready process carries a
  254. 64-bit <code>vruntime</code> and a <code>stride = 2<sup>20</sup> / weight</code>.
  255. While a process runs, its vruntime advances by
  256. <code>elapsed_ms × stride</code>; the scheduler picks the runnable
  257. process with the smallest vruntime. The result is a long-term CPU
  258. share proportional to weight.
  259. </p>
  260. <ul>
  261. <li><strong>10 ms slice.</strong> A running process is preempted at the slice boundary unless it holds the BKL or has preemption disabled.</li>
  262. <li><strong>Global run queue.</strong> A single linked list protected by <code>sched_lock</code>; every CPU scans it for the minimum vruntime.</li>
  263. <li><strong>Wake-up clamp.</strong> A process waking from sleep or a wait queue is moved forward to the current minimum vruntime rather than receiving unlimited credit.</li>
  264. <li><strong>Affinity.</strong> A CPU bitmask restricts where a process may run; kernel threads are pinned to the BSP.</li>
  265. <li><strong><code>renice</code></strong> changes a live process's weight from the shell; the new stride takes effect immediately.</li>
  266. </ul>
  267. <figure class="figure">
  268. <div class="bars" role="img" aria-label="Scheduler weights: window manager 16, default processes and terminals 8, kworker 4, minimum 1. Bar widths are relative to 16.">
  269. <div class="bar-row">
  270. <span class="bar-label">WM / max</span>
  271. <div class="bar-track"><span class="bar-fill" style="--w:100%"></span></div>
  272. <span class="bar-value">16</span>
  273. </div>
  274. <div class="bar-row">
  275. <span class="bar-label">default / terminal</span>
  276. <div class="bar-track"><span class="bar-fill blue" style="--w:50%"></span></div>
  277. <span class="bar-value">8</span>
  278. </div>
  279. <div class="bar-row">
  280. <span class="bar-label">kworker</span>
  281. <div class="bar-track"><span class="bar-fill green" style="--w:25%"></span></div>
  282. <span class="bar-value">4</span>
  283. </div>
  284. <div class="bar-row">
  285. <span class="bar-label">minimum</span>
  286. <div class="bar-track"><span class="bar-fill" style="--w:6.25%"></span></div>
  287. <span class="bar-value">1</span>
  288. </div>
  289. </div>
  290. <figcaption>
  291. <strong>Weights seen in the tree.</strong> The ring-3 WM is raised
  292. to 16, the kworker is set to 4 and a new process starts at 8. Bar
  293. widths are relative to the maximum weight of 16.
  294. </figcaption>
  295. </figure>
  296. <p>
  297. The run queue is a flat list rather than a red-black tree; picking
  298. the minimum is a scan. With at most 64 processes this is simple and
  299. predictable, and the scheduler core stays small enough to audit.
  300. Sleeping processes sit in a sorted sleep list, so the tick handler
  301. wakes due sleepers without scanning every process.
  302. </p>
  303. </section>
  304. <section id="bkl">
  305. <h2>The big kernel lock</h2>
  306. <p>
  307. <code>bkl_*</code> is a sleeping recursive mutex, not a spinlock.
  308. Every ring-3 syscall and every kernel thread takes it; voluntary
  309. block and sleep points release it through <code>sched_yield</code>.
  310. Long serial and network waits use <code>bkl_pause()</code> /
  311. <code>bkl_resume()</code> so another CPU can make progress.
  312. </p>
  313. <ul>
  314. <li><strong>Not timer-preempted.</strong> A CPU running a BKL holder is skipped by the tick decision, so the owner can safely be in the middle of kernel data structures.</li>
  315. <li><strong>Recursive.</strong> The owner may re-enter; the depth is restored across a block in the PCB's <code>bkl_saved</code> field.</li>
  316. <li><strong>Sleep, not spin.</strong> A waiter blocks on the BKL wait queue and is woken when the owner releases.</li>
  317. <li><strong>Lock-free clock.</strong> <code>SYS_GET_TICKS_MS</code> is answered before the lock is taken (one aligned counter read). It is the hottest syscall: QuickJS's interrupt check called it every ~10000 operations and slept on a contended lock each time, and the browser's interrupt hook now reads the clock only every 16th check.</li>
  318. <li><strong>Contention statistics.</strong> <code>sched</code> prints how often a taker had to sleep, the total wait and the longest single hold with its holder, all since the previous <code>sched</code>.</li>
  319. <li><strong>Idle uses trylock.</strong> The idle fallback never blocks on the BKL; kworker and kernel commands take it normally.</li>
  320. </ul>
  321. <div class="note">
  322. <p><strong>Why one big lock?</strong> The kernel is small and not
  323. designed around fine-grained locking. The BKL keeps every kernel
  324. invariant simple, at the cost of serializing long kernel operations.
  325. Disk I/O still holds it, except a destructive format's raw-sector
  326. loop, which releases it so the WM and terminals keep running;
  327. network and serial waits drop it.</p>
  328. </div>
  329. </section>
  330. <section id="idle">
  331. <h2>Idle, power &amp; thermals</h2>
  332. <p>
  333. <code>idle auto</code> is the default. It asks <span class="file">power.c</span>
  334. for the deepest usable hint: C6 (<code>0x20</code>) on
  335. Nehalem/Westmere, C6N (<code>0x58</code>) on Airmont/Braswell when
  336. CPUID advertises the C6 substates, and HLT on the older Atom boards
  337. where an old USB-legacy SMM hang made deep states risky.
  338. </p>
  339. <ul>
  340. <li><strong>Nehalem/Westmere P-states.</strong> <code>power_init</code> enables SpeedStep, raises the package C-state limit to C6 when unlocked, reads min/max ratios from <code>PLATFORM_INFO</code> and starts at the maximum non-turbo ratio. The target ratio goes in bits 15:8 of <code>IA32_PERF_CTL</code> with the low byte zero.</li>
  341. <li><strong>Airmont/Braswell P-states.</strong> Family 6 model <code>0x4C</code> reads the Atom ratio/VID MSRs (<code>0x66A..0x66D</code>), <code>MSR_FSB_FREQ</code> and the FSB table. The N3060 reports pstates 6..20, BCLK 80 MHz (1600 MHz nominal), turbo pstate 31 (2480 MHz) and VID 0x2D..0x3C. <code>power_init</code> enters at max non-turbo and the governor drops to pstate 6 (480 MHz); <code>IA32_PERF_CTL</code> carries the pstate in 15:8 and the Linux-interpolated VID in 7:0. Turbo is detected but not requested. The probe deliberately avoids package/power-SKU MSRs; an unsupported <code>rdmsr</code> before the IDT triple-faults.</li>
  342. <li><strong>Governor.</strong> A 100 ms window picks min/max/linear target pstates; short busy streaks jump to max immediately. Each CPU writes its own <code>IA32_PERF_CTL</code>; <code>cpufreq [auto|min|max|off|&lt;pstate&gt;]</code> overrides it, and <code>SYS_CPUFREQ</code> exposes the same auto/min/max/off mode to the control panel's Power mode tile.</li>
  343. <li><strong>Telemetry.</strong> <code>power</code> prints effective MHz from APERF/MPERF, the current/requested pstate and, on Airmont, the FSB, nominal MHz, turbo pstate/VID, VID range and live <code>PERF_CTL</code>; <code>sensors</code> prints the CPU temperature, board sensors and both EC types; <code>powerinfo</code> prints the AC adapter and battery state, and the WM top bar shows the temperature plus a far-right AC plug or level-filled battery icon on ThinkPads and Chromebooks.</li>
  344. <li><strong>Thermal.</strong> On Intel, each CPU samples its DTS once a second from its scheduler tick; the hottest core is exposed to ring 3. TjMax comes from <code>IA32_TEMPERATURE_TARGET</code> on Nehalem/Westmere, the coretemp 90 °C table on Airmont, and the Bonnell table on older Atoms. On AMD family 15h models below <code>0x60</code> (Bulldozer/Piledriver/Steamroller), <span class="file">thermal.c</span> reads the package Tctl from <code>D18F3xA4</code> at PCI <code>0:18.3</code> (k10temp's <code>(raw × 125) m°C</code>, with the 49 °C range offset when bits 17:16 are both set) and publishes it to every CPU from the kworker under the BKL; PCI config space is deliberately not touched from the per-CPU timer interrupt.</li>
  345. <li><strong>Limits.</strong> Package C-states/S0ix remain firmware-managed; Airmont reports no C3/C6 residency and does not request the turbo pstate. The explicit <code>idle c6</code> override is the Nehalem <code>0x20</code> hint; use <code>idle auto</code> for the Airmont C6N (<code>0x58</code>) path.</li>
  346. </ul>
  347. </section>
  348. <section id="sources">
  349. <h2>Source map</h2>
  350. <ul class="filelist">
  351. <li><code>kernel/sched.c</code>, <code>kernel/sched.h</code> — scheduler core and BKL</li>
  352. <li><code>kernel/process.c</code>, <code>kernel/process.h</code> — PCBs and lifecycle</li>
  353. <li><code>kernel/switch.S</code> — context switch</li>
  354. <li><code>kernel/tss.c</code>, <code>kernel/tss.h</code> — per-CPU TSS</li>
  355. <li><code>kernel/acpi.c</code>, <code>kernel/ioapic.c</code>, <code>kernel/lapic.c</code>, <code>kernel/smp.c</code> — SMP and IOAPIC masking</li>
  356. <li><code>kernel/ap_tramp.S</code> — AP startup blob</li>
  357. <li><code>kernel/timer.S</code>, <code>kernel/idle.c</code>, <code>kernel/power.c</code></li>
  358. <li><code>kernel/thermal.c</code> — Intel DTS and AMD D18F3xA4 sampling</li>
  359. <li><code>kernel/spinlock.h</code> — IRQ-safe spinlocks</li>
  360. </ul>
  361. </section>
  362. </main>
  363. <footer class="site-footer">
  364. <div class="inner">
  365. <p><strong>NebOS 0.2.0</strong> · Architecture documentation · <a href="index.html">overview</a></p>
  366. <p>Maintain alongside <code>AGENTS.md</code> and the source files listed on each page.</p>
  367. </div>
  368. </footer>
  369. </body>
  370. </html>