ap_main()はmp.cにいて、アセンブラで書かれた処理(_trampoline_pm)から呼ばれる。
void ap_main(void) { /* This is the main routine for AP's. This is the entry point before the CPU has been started and jumped to protected mode */ /* Tell BSP we are running */ ap_running_flag=AP_LIFE_FLAG_MARK; /* Now we're ready to take some work. We find any task and call restart() to execute it (or to idle), but we must synchonize other cpus before enter kernel code */ lock_mp_kernel(); /* restart() will unlock later */ /* Enable APIC interrupt aceptance */ enable_cpu(this_cpu,WITHOUT_ECHO); /* Now, kernel is our! */ lock_pick_proc(); /* Is there any work? */ restart(); /* Let's go... */ }
ここまでくると、新しい関数は出てこなくて今まで見てきた関数を使うだけで済んでいる。
ここで必要なのはenable_cpu()を読んでAPを有効にしている部分。
後は、次に動くべきプロセスを選んで(lock_pick_proc())、そのプロセスを動かす(restart())。
restart()はminixに元々ある関数で、kernel/main..cのmain()最後の処理でも使っている。
これでBSP、APが有効になったシステムができているはず。
#ソースでしか追っていないので・・・