ラベル sched の投稿を表示しています。 すべての投稿を表示
ラベル sched の投稿を表示しています。 すべての投稿を表示

2009年9月21日月曜日

preempt_disable

間があいてしまいました。
忘れないうちに今日はpreempt_disableを見てみましょう。

実体はinclude/linux/preempt.hにあります。

======
#define preempt_disable() \
do { \
inc_preempt_count(); \
barrier(); \
} while (0)
======

inc_preempt_countでプリエンプションのカウンタをインクリメントしています。preempt_enableのときは逆にデクリメントします。その後のbarrierは最適化しないでね、とコンパイラに指示するものです。
do-while文ですが条件が0固定なので1度しか実行されません。敢えてdo-whileにしているのでしょうが、なぜなのでしょう?

と思って調べてみたら解説がありました。
[ruby-dev:11748] Re: do while(0)


なるほど。。。

2009年9月7日月曜日

smp_prepare_boot_cp(パス)

次に来るsmp_prepare_boot_cpはSMP構成のみ有効になるコードなのでパスします。
start_kernelの次の部分を見てみましょう。

=====
/*
* Set up the scheduler prior starting any interrupts (such as the
* timer interrupt). Full topology setup happens at smp_init()
* time - but meanwhile we still have a functioning scheduler.
*/
sched_init();
=====

スケジューラの初期化です。
実体はkernel/sched.cにありますが、大きな関数なのでスケジューラ関係は
別の機会にまとめて見てみようと思います。
なのでその次。

=====
/*
* Disable preemption - early bootup scheduling is extremely
* fragile until we cpu_idle() for the first time.
*/
preempt_disable();
build_all_zonelists();
page_alloc_init();
printk(KERN_NOTICE "Kernel command line: %s¥n", boot_command_line);
parse_early_param();
parse_args("Booting kernel", static_command_line, __start___param,
__stop___param - __start___param,
&unknown_bootoption);
if (!irqs_disabled()) {
printk(KERN_WARNING "start_kernel(): bug: interrupts were "
"enabled *very* early, fixing it¥n");
local_irq_disable();
}
sort_main_extable();
trap_init();
rcu_init();

=====

次回から1つずつ追っていこうと思います。