⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 00000045.htm

📁 一份很好的linux入门资料
💻 HTM
📖 第 1 页 / 共 5 页
字号:
rement&nbsp;the&nbsp;corresponding&nbsp;module's&nbsp;reference&nbsp;count&nbsp;<BR>11.&nbsp;The&nbsp;child&nbsp;is&nbsp;marked&nbsp;as&nbsp;'has&nbsp;not&nbsp;execed'&nbsp;p-did_exec&nbsp;=&nbsp;0&nbsp;<BR>12.&nbsp;The&nbsp;child&nbsp;is&nbsp;marked&nbsp;as&nbsp;'not-swappable'&nbsp;p-swappable&nbsp;=&nbsp;0&nbsp;<BR>13.&nbsp;The&nbsp;child&nbsp;is&nbsp;put&nbsp;into&nbsp;'uninterruptible&nbsp;sleep'&nbsp;state&nbsp;p-state&nbsp;=&nbsp;TASK_UNINT&nbsp;<BR>ERRUPTIBLE&nbsp;(TODO:&nbsp;why&nbsp;is&nbsp;this&nbsp;done?&nbsp;I&nbsp;think&nbsp;it's&nbsp;not&nbsp;needed&nbsp;-&nbsp;get&nbsp;rid&nbsp;of&nbsp;it,&nbsp;<BR>&nbsp;Linus&nbsp;confirms&nbsp;it&nbsp;is&nbsp;not&nbsp;needed)&nbsp;<BR>14.&nbsp;The&nbsp;child's&nbsp;p-flags&nbsp;are&nbsp;set&nbsp;according&nbsp;to&nbsp;the&nbsp;value&nbsp;of&nbsp;clone_flags,&nbsp;for&nbsp;t&nbsp;<BR>he&nbsp;plain&nbsp;fork(2)&nbsp;it&nbsp;is&nbsp;p-flags&nbsp;=&nbsp;PF_FORKNOEXEC.&nbsp;<BR>15.&nbsp;The&nbsp;childs&nbsp;pid&nbsp;p-pid&nbsp;is&nbsp;set&nbsp;using&nbsp;the&nbsp;fast&nbsp;algorithm&nbsp;in&nbsp;kernel/fork.c:ge&nbsp;<BR>t_pid()&nbsp;(TODO:&nbsp;lastpid_lock&nbsp;spinlock&nbsp;can&nbsp;be&nbsp;made&nbsp;redundant&nbsp;since&nbsp;get_pid()&nbsp;i&nbsp;<BR>s&nbsp;always&nbsp;called&nbsp;under&nbsp;big&nbsp;kernel&nbsp;lock&nbsp;from&nbsp;do_fork(),&nbsp;also&nbsp;remove&nbsp;flags&nbsp;argu&nbsp;<BR>ment&nbsp;of&nbsp;get_pid,&nbsp;patch&nbsp;sent&nbsp;to&nbsp;Alan&nbsp;on&nbsp;20/06/2000&nbsp;-&nbsp;followup&nbsp;later).&nbsp;<BR>16.&nbsp;The&nbsp;rest&nbsp;of&nbsp;the&nbsp;code&nbsp;in&nbsp;do_fork()&nbsp;initialises&nbsp;the&nbsp;rest&nbsp;of&nbsp;child's&nbsp;task&nbsp;s&nbsp;<BR>tructure.&nbsp;At&nbsp;the&nbsp;very&nbsp;end,&nbsp;the&nbsp;child's&nbsp;task&nbsp;structure&nbsp;is&nbsp;hashed&nbsp;into&nbsp;pidhash&nbsp;<BR>&nbsp;hashtable&nbsp;and&nbsp;the&nbsp;child&nbsp;is&nbsp;woken&nbsp;up&nbsp;(TODO:&nbsp;wake_up_process(p)&nbsp;sets&nbsp;p-state&nbsp;&nbsp;<BR>=&nbsp;TASK_RUNNING&nbsp;and&nbsp;adds&nbsp;the&nbsp;process&nbsp;to&nbsp;the&nbsp;runq,&nbsp;therefore&nbsp;we&nbsp;probably&nbsp;didn'&nbsp;<BR>t&nbsp;need&nbsp;to&nbsp;set&nbsp;p-state&nbsp;to&nbsp;TASK_RUNNING&nbsp;earlier&nbsp;on&nbsp;in&nbsp;do_fork()).&nbsp;The&nbsp;interest&nbsp;<BR>ing&nbsp;part&nbsp;is&nbsp;setting&nbsp;p-exit_signal&nbsp;to&nbsp;clone_flags&nbsp;&amp;&nbsp;CSIGNAL&nbsp;which&nbsp;for&nbsp;fork(2)&nbsp;<BR>&nbsp;means&nbsp;just&nbsp;SIGCHLD&nbsp;and&nbsp;setting&nbsp;p-pdeath_signal&nbsp;to&nbsp;0.&nbsp;The&nbsp;pdeath_signal&nbsp;is&nbsp;u&nbsp;<BR>sed&nbsp;when&nbsp;a&nbsp;process&nbsp;'forgets'&nbsp;the&nbsp;original&nbsp;parent&nbsp;(by&nbsp;dying)&nbsp;and&nbsp;can&nbsp;be&nbsp;set/g&nbsp;<BR>et&nbsp;by&nbsp;means&nbsp;of&nbsp;PR_GET/SET_PDEATHSIG&nbsp;commands&nbsp;of&nbsp;prctl(2)&nbsp;system&nbsp;call&nbsp;(You&nbsp;mi&nbsp;<BR>ght&nbsp;argue&nbsp;that&nbsp;the&nbsp;way&nbsp;the&nbsp;value&nbsp;of&nbsp;pdeath_signal&nbsp;is&nbsp;returned&nbsp;via&nbsp;userspace&nbsp;&nbsp;<BR>pointer&nbsp;argument&nbsp;in&nbsp;prctl(2)&nbsp;is&nbsp;a&nbsp;bit&nbsp;silly&nbsp;-&nbsp;mea&nbsp;culpa,&nbsp;after&nbsp;Andries&nbsp;Brouw&nbsp;<BR>er&nbsp;updated&nbsp;the&nbsp;manpage&nbsp;it&nbsp;was&nbsp;too&nbsp;late&nbsp;to&nbsp;fix&nbsp;;)&nbsp;<BR>Thus&nbsp;tasks&nbsp;are&nbsp;created.&nbsp;There&nbsp;are&nbsp;several&nbsp;ways&nbsp;for&nbsp;tasks&nbsp;to&nbsp;terminate:&nbsp;<BR>1.&nbsp;By&nbsp;making&nbsp;exit(2)&nbsp;system&nbsp;call&nbsp;<BR>2.&nbsp;By&nbsp;being&nbsp;delivered&nbsp;a&nbsp;signal&nbsp;with&nbsp;default&nbsp;disposition&nbsp;to&nbsp;die&nbsp;<BR>3.&nbsp;By&nbsp;being&nbsp;forced&nbsp;to&nbsp;die&nbsp;under&nbsp;certain&nbsp;exceptions&nbsp;<BR>4.&nbsp;By&nbsp;calling&nbsp;bdflush(2)&nbsp;with&nbsp;func&nbsp;==&nbsp;1&nbsp;(this&nbsp;is&nbsp;Linux-specific,&nbsp;for&nbsp;compati&nbsp;<BR>bility&nbsp;with&nbsp;old&nbsp;distributions&nbsp;that&nbsp;still&nbsp;had&nbsp;the&nbsp;'update'&nbsp;line&nbsp;in&nbsp;/etc/initt&nbsp;<BR>ab&nbsp;-&nbsp;nowadays&nbsp;the&nbsp;work&nbsp;of&nbsp;update&nbsp;is&nbsp;done&nbsp;by&nbsp;kernel&nbsp;thread&nbsp;kupdate&nbsp;<BR>Functions&nbsp;implementing&nbsp;system&nbsp;calls&nbsp;under&nbsp;Linux&nbsp;are&nbsp;prefixed&nbsp;with&nbsp;'sys_',&nbsp;bu&nbsp;<BR>t&nbsp;they&nbsp;are&nbsp;usually&nbsp;concerned&nbsp;only&nbsp;with&nbsp;argument&nbsp;checking&nbsp;or&nbsp;arch-specific&nbsp;wa&nbsp;<BR>ys&nbsp;to&nbsp;pass&nbsp;some&nbsp;information&nbsp;and&nbsp;the&nbsp;actual&nbsp;work&nbsp;is&nbsp;done&nbsp;by&nbsp;'do_'&nbsp;functions.&nbsp;&nbsp;<BR>So&nbsp;it&nbsp;is&nbsp;with&nbsp;sys_exit()&nbsp;which&nbsp;calls&nbsp;do_exit()&nbsp;to&nbsp;do&nbsp;the&nbsp;work.&nbsp;Although,&nbsp;oth&nbsp;<BR>er&nbsp;parts&nbsp;of&nbsp;the&nbsp;kernel&nbsp;sometimes&nbsp;invoke&nbsp;sys_exit(),&nbsp;they&nbsp;should&nbsp;really&nbsp;call&nbsp;&nbsp;<BR>do_exit().&nbsp;<BR>The&nbsp;function&nbsp;do_exit()&nbsp;is&nbsp;found&nbsp;in&nbsp;kernel/exit.c.&nbsp;The&nbsp;points&nbsp;to&nbsp;note&nbsp;about&nbsp;d&nbsp;<BR>o_exit():&nbsp;<BR>·&nbsp;Uses&nbsp;global&nbsp;kernel&nbsp;lock&nbsp;(locks&nbsp;but&nbsp;doesn't&nbsp;unlock)&nbsp;<BR>·&nbsp;Calls&nbsp;schedule()&nbsp;at&nbsp;the&nbsp;end&nbsp;which&nbsp;never&nbsp;returns&nbsp;<BR>·&nbsp;Sets&nbsp;the&nbsp;task&nbsp;state&nbsp;to&nbsp;TASK_ZOMBIE&nbsp;<BR>·&nbsp;Notifies&nbsp;any&nbsp;child&nbsp;with&nbsp;current-pdeath_signal,&nbsp;if&nbsp;not&nbsp;0&nbsp;<BR>·&nbsp;Notifies&nbsp;the&nbsp;parent&nbsp;with&nbsp;a&nbsp;current-exit_signal,&nbsp;which&nbsp;is&nbsp;usually&nbsp;equal&nbsp;to&nbsp;<BR>&nbsp;SIGCHLD&nbsp;<BR>·&nbsp;Releases&nbsp;resources&nbsp;allocated&nbsp;by&nbsp;fork,&nbsp;closes&nbsp;open&nbsp;files&nbsp;etc&nbsp;<BR>·&nbsp;On&nbsp;architectures&nbsp;that&nbsp;use&nbsp;lazy&nbsp;FPU&nbsp;switching&nbsp;(ia64,&nbsp;mips,&nbsp;mips64,&nbsp;(TODO:&nbsp;&nbsp;<BR>remove&nbsp;'flags'&nbsp;argument&nbsp;of&nbsp;sparc,&nbsp;sparc64)&nbsp;do&nbsp;whatever&nbsp;the&nbsp;hardware&nbsp;requires&nbsp;<BR>&nbsp;to&nbsp;pass&nbsp;the&nbsp;FPU&nbsp;ownership&nbsp;(if&nbsp;owned&nbsp;by&nbsp;current)&nbsp;to&nbsp;&quot;none&quot;&nbsp;<BR>2.3&nbsp;Linux&nbsp;Scheduler&nbsp;<BR>The&nbsp;job&nbsp;of&nbsp;a&nbsp;scheduler&nbsp;is&nbsp;to&nbsp;arbitrate&nbsp;access&nbsp;to&nbsp;the&nbsp;current&nbsp;CPU&nbsp;between&nbsp;mul&nbsp;<BR>tiple&nbsp;processes.&nbsp;Scheduler&nbsp;is&nbsp;implemented&nbsp;in&nbsp;the&nbsp;'main&nbsp;kernel&nbsp;file'&nbsp;kernel/s&nbsp;<BR>ched.c.&nbsp;The&nbsp;corresponding&nbsp;header&nbsp;file&nbsp;include/linux/sched.h&nbsp;is&nbsp;included&nbsp;(eit&nbsp;<BR>her&nbsp;explicitly&nbsp;or&nbsp;indirectly)&nbsp;by&nbsp;virtually&nbsp;every&nbsp;kernel&nbsp;source&nbsp;file.&nbsp;<BR>The&nbsp;fields&nbsp;of&nbsp;task&nbsp;structure&nbsp;relevant&nbsp;to&nbsp;scheduler&nbsp;include:&nbsp;<BR>·&nbsp;p-need_resched,&nbsp;set&nbsp;if&nbsp;schedule()&nbsp;should&nbsp;be&nbsp;invoked&nbsp;at&nbsp;the&nbsp;'next&nbsp;opportun&nbsp;<BR>ity'&nbsp;<BR>·&nbsp;p-counter,&nbsp;number&nbsp;of&nbsp;clock&nbsp;ticks&nbsp;left&nbsp;to&nbsp;run&nbsp;in&nbsp;this&nbsp;scheduling&nbsp;slice,&nbsp;de&nbsp;<BR>cremented&nbsp;by&nbsp;timer.&nbsp;When&nbsp;goes&nbsp;below&nbsp;or&nbsp;equal&nbsp;zero&nbsp;is&nbsp;reset&nbsp;to&nbsp;0&nbsp;and&nbsp;p-need_r&nbsp;<BR>esched&nbsp;set.&nbsp;This&nbsp;is&nbsp;also&nbsp;sometimes&nbsp;called&nbsp;'dynamic&nbsp;priority'&nbsp;of&nbsp;a&nbsp;process&nbsp;be&nbsp;<BR>cause&nbsp;it&nbsp;can&nbsp;change&nbsp;by&nbsp;itself&nbsp;<BR>·&nbsp;p-priority,&nbsp;static&nbsp;priority,&nbsp;only&nbsp;changed&nbsp;through&nbsp;well-known&nbsp;system&nbsp;calls&nbsp;<BR>&nbsp;like&nbsp;nice(2),&nbsp;POSIX.1b&nbsp;sched_setparam(2)&nbsp;or&nbsp;4.4BSD/SVR4&nbsp;setpriority(2)&nbsp;<BR>·&nbsp;p-rt_priority,&nbsp;realtime&nbsp;priority&nbsp;<BR>·&nbsp;p-policy,&nbsp;scheduling&nbsp;policy,&nbsp;specifies&nbsp;which&nbsp;scheduling&nbsp;class&nbsp;the&nbsp;task&nbsp;be&nbsp;<BR>longs&nbsp;to.&nbsp;Tasks&nbsp;can&nbsp;change&nbsp;their&nbsp;scheduling&nbsp;class&nbsp;using&nbsp;sched_setscheduler(2&nbsp;<BR>)&nbsp;system&nbsp;call.&nbsp;The&nbsp;valid&nbsp;values&nbsp;are&nbsp;SCHED_OTHER&nbsp;(traditional&nbsp;UNIX&nbsp;process),&nbsp;&nbsp;<BR>SCHED_FIFO&nbsp;(POSIX.1b&nbsp;FIFO&nbsp;realtime&nbsp;process)&nbsp;and&nbsp;SCHED_RR&nbsp;(POSIX&nbsp;round-robin&nbsp;&nbsp;<BR>realtime&nbsp;process).&nbsp;One&nbsp;can&nbsp;also&nbsp;OR&nbsp;SCHED_YIELD&nbsp;to&nbsp;any&nbsp;of&nbsp;these&nbsp;values&nbsp;to&nbsp;sig&nbsp;<BR>nify&nbsp;that&nbsp;the&nbsp;process&nbsp;decided&nbsp;to&nbsp;yield&nbsp;the&nbsp;CPU,&nbsp;for&nbsp;example&nbsp;by&nbsp;calling&nbsp;sched&nbsp;<BR>_yield(2)&nbsp;system&nbsp;call.&nbsp;FIFO&nbsp;realtime&nbsp;process&nbsp;runs&nbsp;until&nbsp;either&nbsp;a)&nbsp;it&nbsp;blocks&nbsp;&nbsp;<BR>on&nbsp;I/O&nbsp;b)&nbsp;explicitly&nbsp;yields&nbsp;the&nbsp;CPU&nbsp;or&nbsp;c)&nbsp;is&nbsp;preempted&nbsp;by&nbsp;another&nbsp;realtime&nbsp;p&nbsp;<BR>rocess&nbsp;with&nbsp;a&nbsp;higher&nbsp;p-rt_priority&nbsp;value.&nbsp;SCHED_RR&nbsp;is&nbsp;same&nbsp;as&nbsp;SCHED_FIFO&nbsp;exc&nbsp;<BR>ept&nbsp;that&nbsp;when&nbsp;it's&nbsp;timeslice&nbsp;expires&nbsp;it&nbsp;goes&nbsp;back&nbsp;to&nbsp;the&nbsp;end&nbsp;of&nbsp;the&nbsp;runqueue&nbsp;<BR>&nbsp;<BR>The&nbsp;scheduler's&nbsp;algorithm&nbsp;is&nbsp;simple,&nbsp;despite&nbsp;the&nbsp;great&nbsp;apparent&nbsp;complexity&nbsp;o&nbsp;<BR>f&nbsp;the&nbsp;schedule()&nbsp;function.&nbsp;The&nbsp;function&nbsp;is&nbsp;complex&nbsp;because&nbsp;it&nbsp;implements&nbsp;thr&nbsp;<BR>ee&nbsp;scheduling&nbsp;algorithms&nbsp;in&nbsp;one&nbsp;and&nbsp;also&nbsp;because&nbsp;of&nbsp;the&nbsp;subtle&nbsp;SMP-specifics&nbsp;<BR>.&nbsp;<BR>The&nbsp;apparently&nbsp;'useless'&nbsp;gotos&nbsp;in&nbsp;schedule()&nbsp;are&nbsp;there&nbsp;for&nbsp;a&nbsp;purpose&nbsp;-&nbsp;to&nbsp;ge&nbsp;<BR>nerate&nbsp;the&nbsp;best&nbsp;optimized&nbsp;(for&nbsp;i386)&nbsp;code.&nbsp;Also,&nbsp;note&nbsp;that&nbsp;scheduler&nbsp;(like&nbsp;m&nbsp;<BR>ost&nbsp;of&nbsp;the&nbsp;kernel)&nbsp;was&nbsp;completely&nbsp;rewritten&nbsp;for&nbsp;2.4&nbsp;so&nbsp;the&nbsp;discussion&nbsp;below&nbsp;&nbsp;<BR>does&nbsp;not&nbsp;apply&nbsp;to&nbsp;2.2&nbsp;or&nbsp;to&nbsp;any&nbsp;other&nbsp;old&nbsp;kernels.&nbsp;<BR>Let&nbsp;us&nbsp;look&nbsp;at&nbsp;the&nbsp;function&nbsp;in&nbsp;detail:&nbsp;<BR>1.&nbsp;if&nbsp;current-active_mm&nbsp;==&nbsp;NULL&nbsp;then&nbsp;something&nbsp;is&nbsp;wrong.&nbsp;Current&nbsp;process,&nbsp;ev&nbsp;<BR>en&nbsp;a&nbsp;kernel&nbsp;thread&nbsp;(current-mm&nbsp;==&nbsp;NULL)&nbsp;must&nbsp;have&nbsp;a&nbsp;valid&nbsp;p-active_mm&nbsp;at&nbsp;all&nbsp;<BR>&nbsp;times&nbsp;<BR>2.&nbsp;if&nbsp;there&nbsp;is&nbsp;something&nbsp;to&nbsp;do&nbsp;on&nbsp;tq_scheduler&nbsp;task&nbsp;queue,&nbsp;process&nbsp;it&nbsp;now.&nbsp;T&nbsp;<BR>ask&nbsp;queues&nbsp;provide&nbsp;a&nbsp;kernel&nbsp;mechanism&nbsp;to&nbsp;schedule&nbsp;execution&nbsp;of&nbsp;functions&nbsp;at&nbsp;&nbsp;<BR>a&nbsp;later&nbsp;time.&nbsp;We&nbsp;shall&nbsp;look&nbsp;at&nbsp;it&nbsp;in&nbsp;details&nbsp;elsewhere.&nbsp;<BR>3.&nbsp;initialize&nbsp;local&nbsp;variables&nbsp;prev&nbsp;and&nbsp;this_cpu&nbsp;to&nbsp;current&nbsp;task&nbsp;and&nbsp;current&nbsp;&nbsp;<BR>CPU&nbsp;respectively&nbsp;<BR>4.&nbsp;check&nbsp;if&nbsp;schedule()&nbsp;was&nbsp;invoked&nbsp;from&nbsp;interrupt&nbsp;handler&nbsp;(due&nbsp;to&nbsp;a&nbsp;bug)&nbsp;and&nbsp;<BR>&nbsp;panic&nbsp;if&nbsp;so&nbsp;<BR>5.&nbsp;release&nbsp;the&nbsp;global&nbsp;kernel&nbsp;lock&nbsp;<BR>6.&nbsp;if&nbsp;there&nbsp;is&nbsp;some&nbsp;work&nbsp;to&nbsp;do&nbsp;via&nbsp;softirq&nbsp;mechanism&nbsp;do&nbsp;it&nbsp;now&nbsp;<BR>7.&nbsp;initialize&nbsp;local&nbsp;pointer&nbsp;'struct&nbsp;schedule_data&nbsp;*sched_data'&nbsp;to&nbsp;point&nbsp;to&nbsp;p&nbsp;<BR>er-CPU&nbsp;(cacheline-aligned&nbsp;to&nbsp;prevent&nbsp;cacheline&nbsp;ping-pong)&nbsp;scheduling&nbsp;data&nbsp;ar&nbsp;<BR>ea&nbsp;containing&nbsp;TSC&nbsp;value&nbsp;of&nbsp;last_schedule&nbsp;and&nbsp;the&nbsp;pointer&nbsp;to&nbsp;last&nbsp;scheduled&nbsp;t&nbsp;<BR>ask&nbsp;structure&nbsp;(TODO:&nbsp;sched_data&nbsp;is&nbsp;used&nbsp;on&nbsp;SMP&nbsp;only&nbsp;but&nbsp;why&nbsp;does&nbsp;init_idle()&nbsp;<BR>&nbsp;initialises&nbsp;it&nbsp;on&nbsp;UP&nbsp;as&nbsp;well?)&nbsp;<BR>8.&nbsp;runqueue_lock&nbsp;spinlock&nbsp;is&nbsp;taken.&nbsp;Note&nbsp;that&nbsp;we&nbsp;use&nbsp;spin_lock_irq()&nbsp;because&nbsp;<BR>&nbsp;in&nbsp;schedule()&nbsp;we&nbsp;guarantee&nbsp;that&nbsp;interrupts&nbsp;are&nbsp;enabled&nbsp;so&nbsp;when&nbsp;we&nbsp;unlock&nbsp;ru&nbsp;<BR>nqueue_lock&nbsp;we&nbsp;can&nbsp;just&nbsp;re-enable&nbsp;them&nbsp;instead&nbsp;of&nbsp;saving/restoring&nbsp;eflags&nbsp;(s&nbsp;<BR>pin_lock_irqsave/restore&nbsp;variant)&nbsp;<BR>9.&nbsp;task&nbsp;state&nbsp;machine:&nbsp;if&nbsp;the&nbsp;task&nbsp;is&nbsp;in&nbsp;TASK_RUNNING&nbsp;state&nbsp;it&nbsp;is&nbsp;left&nbsp;alone&nbsp;<BR>,&nbsp;if&nbsp;it&nbsp;is&nbsp;in&nbsp;TASK_INTERRUPTIBLE&nbsp;and&nbsp;a&nbsp;signal&nbsp;is&nbsp;pending&nbsp;then&nbsp;it&nbsp;is&nbsp;moved&nbsp;in&nbsp;<BR>to&nbsp;TASK_RUNNING&nbsp;state.&nbsp;In&nbsp;all&nbsp;other&nbsp;cases&nbsp;it&nbsp;is&nbsp;deleted&nbsp;from&nbsp;the&nbsp;runqueue&nbsp;<BR>10.&nbsp;next&nbsp;(best&nbsp;candidate&nbsp;to&nbsp;be&nbsp;scheduled)&nbsp;is&nbsp;set&nbsp;to&nbsp;the&nbsp;idle&nbsp;task&nbsp;of&nbsp;this&nbsp;cp&nbsp;<BR>u.&nbsp;However,&nbsp;the&nbsp;goodness&nbsp;of&nbsp;this&nbsp;candidate&nbsp;is&nbsp;set&nbsp;to&nbsp;a&nbsp;very&nbsp;low&nbsp;value&nbsp;of&nbsp;-10&nbsp;<BR>00&nbsp;in&nbsp;hope&nbsp;that&nbsp;there&nbsp;is&nbsp;someone&nbsp;better&nbsp;than&nbsp;that.&nbsp;<BR>11.&nbsp;if&nbsp;the&nbsp;prev&nbsp;(current)&nbsp;task&nbsp;is&nbsp;in&nbsp;TASK_RUNNING&nbsp;state,&nbsp;then&nbsp;the&nbsp;current&nbsp;go&nbsp;<BR>odness&nbsp;is&nbsp;set&nbsp;to&nbsp;its&nbsp;goodness&nbsp;and&nbsp;it&nbsp;is&nbsp;marked&nbsp;as&nbsp;a&nbsp;better&nbsp;candidate&nbsp;to&nbsp;be&nbsp;s&nbsp;<BR>cheduled&nbsp;than&nbsp;the&nbsp;idle&nbsp;task&nbsp;<BR>12.&nbsp;now&nbsp;the&nbsp;runqueue&nbsp;is&nbsp;examined&nbsp;and&nbsp;a&nbsp;goodness&nbsp;of&nbsp;each&nbsp;process&nbsp;that&nbsp;can&nbsp;be&nbsp;&nbsp;<BR>scheduled&nbsp;on&nbsp;this&nbsp;cpu&nbsp;is&nbsp;compared&nbsp;with&nbsp;current&nbsp;value&nbsp;and&nbsp;the&nbsp;process&nbsp;with&nbsp;hi&nbsp;<BR>ghest&nbsp;goodness&nbsp;wins.&nbsp;Now&nbsp;the&nbsp;concept&nbsp;of&nbsp;&quot;can&nbsp;be&nbsp;scheduled&nbsp;on&nbsp;this&nbsp;cpu&quot;&nbsp;must&nbsp;&nbsp;<BR>be&nbsp;clarified&nbsp;-&nbsp;on&nbsp;UP&nbsp;every&nbsp;process&nbsp;on&nbsp;the&nbsp;runqueue&nbsp;is&nbsp;eligible&nbsp;to&nbsp;be&nbsp;schedul&nbsp;<BR>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -