ºìÁªLinuxÃÅ»§
Linux°ïÖú

LinuxÓû§Ïß³ÌÔÚÄÚºËÖеıíÏÖ

·¢²¼Ê±¼ä:2008-08-26 16:41:52À´Ô´:ºìÁª×÷Õß:5trnga
Ô­´´£ºSoHo

±¾ÎÄÊÔͼ½âÊÍLinuxÖÐÓû§Ï̴߳´½¨ºÍÔËÐеÄÔ­Àí£¬ÕâÀï²»Éæ¼°ÄÚºËÏ̡߳£

Äں˹ÜÀíÏ̵߳Ľṹ

task_struct
Ïß³ÌËùÓÐÏà¹ØÐÅÏ¢£¬ÅÓ´ó

thread_info
Ïß³ÌÉÙÁ¿Ïà¹ØÐÅÏ¢£¬¿ÉÒԷŽøÒ»¸öcache line

ÄÚºËÕ»
Ïß³ÌÔÚÄÚºË̬ÔËÐÐʱµÄÕ»£¬Ò»°ãΪ2Ò³£¬8KB

thread_info½á¹¹´æ·ÅÔÚÄÚºËÕ»¶¥£¬Õ»µ×µØַΪ£¨thread_info+THREAD_SIZE-40£©£¬ÕâÀï¼ÙÉèÕ»´Óµ×Íù¶¥Éý

µÚÒ»¸öÏß³Ì
µÚ¶þÖ»¼¦ÓɵÚÒ»Ö»¼¦¸´ÖƵÃÀ´£¬µÚÈýÖ»¼¦ÓɵڶþÖ»¼¦¸´ÖƵÃÀ´£¬ÒÀ´ËÀàÍÆ£¬µ«ÊÇÎÊÌâÊÇ£ºµÚÒ»Ö»¼¦´ÓÄÄÀïÀ´£¿

ÔÚLinuxϵͳÖУ¬µÚÒ»¸öÏ̵߳Ätask_structΪinit_task£¬thread_infoΪinit_thread_info£¬ÄÚºËջΪinit_stack£¬¶¼ÊÇÖ±½ÓÔ¤Áô¿Õ¼ä¡¢Ö±½Ó³õʼ»¯

×ÓËïÏß³Ì
ϵͳÖÐËùÓÐÏ̶߳¼ÊÇinit_taskµÄ×ÓËËûÃÇͨ¹ýÉêÇëÄÚ´æµÃµ½task_struct¡¢thread_infoºÍÄÚºËÕ»£¬ÇÒÓÃÆ丸½ø³ÌµÄÏàÓ¦ÐÅÏ¢³õʼ»¯£¬µ«ÊǸü¸ÄÉÙÁ¿ÆäÌØÓеıäÁ¿£¬ÈçPID

forkÓëexec
forkÓÃÓÚ´´½¨×Ó½ø³ÌµÄtask_struct¡¢thread_infoºÍÄÚºËÕ»£¬µ«ÊÇÖ´ÐеĴúÂëºÍ¸¸½ø³ÌÒ»Ñù

Èç¹û×Ó½ø³ÌÏ£ÍûÖ´ÐÐÆäËû´úÂ룬ÔòÐèÒªµ÷ÓÃexec

other
ÎÄÕÂÆÀÂÛ

¹²ÓÐ 0 ÌõÆÀÂÛ