linux-0.01 読み (14)
task[0] の謎の巻
ええと以下な記述が system_call 手続きの中にあるんですが
movl current,%eax # task[0] cannot have signals cmpl task,%eax je 3f
task_struct な配列の先頭要素に何が格納されているのか、というと
struct task_struct * task[NR_TASKS] = {&(init_task.task), };
との事。
この init_task.task の定義は直上にて以下。
union task_union { struct task_struct task; char stack[PAGE_SIZE]; }; static union task_union init_task = {INIT_TASK,};
何故に char な配列との共用体になってるのかは謎。で、INIT_TASK の定義を掘削してみたら sched.h で以下なのか。
/* * INIT_TASK is used to set up the first task table, touch at * your own risk!. Base=0, limit=0x9ffff (=640kB) */ #define INIT_TASK \ /* state etc */ { 0,15,15, \ /* signals */ 0,NULL,{(fn_ptr) 0,}, \ /* ec,brk... */ 0,0,0,0,0, \ /* pid etc.. */ 0,-1,0,0,0, \ /* uid etc */ 0,0,0,0,0,0, \ /* alarm */ 0,0,0,0,0,0, \ /* math */ 0, \ /* fs info */ -1,0133,NULL,NULL,0, \ /* filp */ {NULL,}, \ { \ {0,0}, \ /* ldt */ {0x9f,0xc0fa00}, \ {0x9f,0xc0f200}, \ }, \ /*tss*/ {0,PAGE_SIZE+(long)&init_task,0x10,0,0,0,0,(long)&pg_dir,\ 0,0,0,0,0,0,0,0, \ 0,0,0x17,0x17,0x17,0x17,0x17,0x17, \ _LDT(0),0x80000000, \ {} \ }, \ }
なんだこれわ。ちなみにこの task[0] は FIRST_TASK として define されてて kernel/sched.c および kernel/exit.c にて使われているのを確認。これってアイドルダスクってやつかな。多分そうだな。
てゆーか
やはり現実トウヒな取り組みは生産性が良いというかノリが良いな (何