LinuxÄÚºËÖ÷ÒªÓÉÎå¸ö×Óϵͳ×é³É£º½ø³Ìµ÷¶È£¬ÄÚ´æ¹ÜÀí£¬ÐéÄâÎļþϵͳ£¬ÍøÂç½Ó¿Ú£¬½ø³Ì¼äͨÐÅ¡£
1.½ø³Ìµ÷¶È£¨SCHED£©:¿ØÖƽø³Ì¶ÔCPUµÄ·ÃÎÊ¡£µ±ÐèҪѡÔñÏÂÒ»¸ö½ø³ÌÔËÐÐʱ£¬Óɵ÷¶È³ÌÐòÑ¡Ôñ×îÖµµÃÔËÐеĽø³Ì¡£¿ÉÔËÐнø³Ìʵ¼ÊÉÏÊǽöµÈ´ýCPU×ÊÔ´µÄ½ø³Ì£¬Èç¹ûij¸ö½ø³ÌÔڵȴýÆäËü×ÊÔ´£¬Ôò¸Ã½ø³ÌÊDz»¿ÉÔËÐнø³Ì¡£LinuxʹÓÃÁ˱Ƚϼòµ¥µÄ»ùÓÚÓÅÏȼ¶µÄ½ø³Ìµ÷¶ÈË㷨ѡÔñеĽø³Ì¡£
2.ÄÚ´æ¹ÜÀí£¨MM£©ÔÊÐí¶à¸ö½ø³Ì°²È«µÄ¹²ÏíÖ÷ÄÚ´æÇøÓò¡£LinuxµÄÄÚ´æ¹ÜÀíÖ§³ÖÐéÄâÄڴ棬¼´ÔÚ¼ÆËã»úÖÐÔËÐеijÌÐò£¬Æä´úÂ룬Êý¾Ý£¬¶ÑÕ»µÄ×ÜÁ¿¿ÉÒÔ³¬¹ýʵ¼ÊÄÚ´æµÄ´óС£¬²Ù×÷ϵͳֻÊǰѵ±Ç°Ê¹ÓõijÌÐò¿é±£ÁôÔÚÄÚ´æÖУ¬ÆäÓàµÄ³ÌÐò¿éÔò±£ÁôÔÚ´ÅÅÌÖС£±ØҪʱ£¬²Ù×÷ϵͳ¸ºÔðÔÚ´ÅÅ̺ÍÄÚ´æ¼ä½»»»³ÌÐò¿é¡£ÄÚ´æ¹ÜÀí´ÓÂß¼ÉÏ·ÖΪӲ¼þÎ޹ز¿·ÖºÍÓ²¼þÓйز¿·Ö¡£Ó²¼þÎ޹ز¿·ÖÌṩÁ˽ø³ÌµÄÓ³ÉäºÍÂß¼ÄÚ´æµÄ¶Ô»»£»Ó²¼þÏà¹ØµÄ²¿·ÖΪÄÚ´æ¹ÜÀíÓ²¼þÌṩÁËÐéÄâ½Ó¿Ú¡£
3.ÐéÄâÎļþϵͳ£¨VirtualFileSystem,VFS£©Òþ²ØÁ˸÷ÖÖÓ²¼þµÄ¾ßÌåϸ½Ú£¬ÎªËùÓеÄÉ豸ÌṩÁËͳһµÄ½Ó¿Ú£¬VFSÌṩÁ˶à´ïÊýÊ®ÖÖ²»Í¬µÄÎļþϵͳ¡£ÐéÄâÎļþϵͳ¿ÉÒÔ·ÖΪÂß¼ÎļþϵͳºÍÉ豸Çý¶¯³ÌÐò¡£Âß¼ÎļþϵͳָLinuxËùÖ§³ÖµÄÎļþϵͳ£¬Èçext2,fatµÈ£¬É豸Çý¶¯³ÌÐòָΪÿһÖÖÓ²¼þ¿ØÖÆÆ÷Ëù±àдµÄÉ豸Çý¶¯³ÌÐòÄ£¿é¡£
4.ÍøÂç½Ó¿Ú£¨NET£©ÌṩÁ˶Ը÷ÖÖÍøÂç±ê×¼µÄ´æÈ¡ºÍ¸÷ÖÖÍøÂçÓ²¼þµÄÖ§³Ö¡£ÍøÂç½Ó¿Ú¿É·ÖΪÍøÂçÐÒéºÍÍøÂçÇý¶¯³ÌÐò¡£ÍøÂçÐÒ鲿·Ö¸ºÔðʵÏÖÿһÖÖ¿ÉÄܵÄÍøÂç´«ÊäÐÒé¡£ÍøÂçÉ豸Çý¶¯³ÌÐò¸ºÔðÓëÓ²¼þÉ豸ͨѶ£¬Ã¿Ò»ÖÖ¿ÉÄܵÄÓ²¼þÉ豸¶¼ÓÐÏàÓ¦µÄÉ豸Çý¶¯³ÌÐò¡£
5.½ø³Ì¼äͨѶ(IPC) Ö§³Ö½ø³Ì¼ä¸÷ÖÖͨÐÅ»úÖÆ¡£
´¦ÓÚÖÐÐÄλÖõĽø³Ìµ÷¶È£¬ËùÓÐÆäËüµÄ×Óϵͳ¶¼ÒÀÀµËü£¬ÒòΪÿ¸ö×Óϵͳ¶¼ÐèÒª¹ÒÆð»ò»Ö¸´½ø³Ì¡£Ò»°ãÇé¿öÏ£¬µ±Ò»¸ö½ø³ÌµÈ´ýÓ²¼þ²Ù×÷Íê³Éʱ£¬Ëü±»¹ÒÆ𣻵±²Ù×÷ÕæÕýÍê³Éʱ£¬½ø³Ì±»»Ö¸´Ö´ÐС£ÀýÈ磬µ±Ò»¸ö½ø³Ìͨ¹ýÍøÂç·¢ËÍÒ»ÌõÏûϢʱ£¬ÍøÂç½Ó¿ÚÐèÒª¹ÒÆð·¢Ëͽø³Ì£¬Ö±µ½Ó²¼þ³É¹¦µØÍê³ÉÏûÏ¢µÄ·¢ËÍ£¬µ±ÏûÏ¢±»³É¹¦µÄ·¢ËͳöÈ¥ÒÔºó£¬ÍøÂç½Ó¿Ú¸ø½ø³Ì·µ»ØÒ»¸ö´úÂ룬±íʾ²Ù×÷µÄ³É¹¦»òʧ°Ü¡£ÆäËû×ÓϵͳÒÔÏàËƵÄÀíÓÉÒÀÀµÓÚ½ø³Ìµ÷¶È¡£
¸÷¸ö×Óϵͳ֮¼äµÄÒÀÀµ¹ØϵÈçÏ£º
½ø³Ìµ÷¶ÈÓëÄÚ´æ¹ÜÀíÖ®¼äµÄ¹Øϵ£ºÕâÁ½¸ö×Óϵͳ»¥ÏàÒÀÀµ¡£ÔÚ¶àµÀ³ÌÐò»·¾³Ï£¬³ÌÐòÒªÔËÐбØÐëΪ֮´´½¨½ø³Ì£¬¶ø´´½¨½ø³ÌµÄµÚÒ»¼þÊÂÇ飬¾ÍÊǽ«³ÌÐòºÍÊý¾Ý×°ÈëÄÚ´æ¡£
½ø³Ì¼äͨÐÅÓëÄÚ´æ¹ÜÀíµÄ¹Øϵ£º½ø³Ì¼äͨÐÅ×ÓϵͳҪÒÀÀµÄÚ´æ¹ÜÀíÖ§³Ö¹²ÏíÄÚ´æͨÐÅ»úÖÆ£¬ÕâÖÖ»úÖÆÔÊÐíÁ½¸ö½ø³Ì³ýÁËÓµÓÐ×Ô¼ºµÄ˽Óпռ䣬»¹¿ÉÒÔ´æÈ¡¹²Í¬µÄÄÚ´æÇøÓò¡£
ÐéÄâÎļþϵͳÓëÍøÂç½Ó¿ÚÖ®¼äµÄ¹Øϵ£ºÐéÄâÎļþϵͳÀûÓÃÍøÂç½Ó¿ÚÖ§³ÖÍøÂçÎļþϵͳ(NFS),Ò²ÀûÓÃÄÚ´æ¹ÜÀíÖ§³ÖRAMDISKÉ豸¡£
ÄÚ´æ¹ÜÀíÓëÐéÄâÎļþϵͳ֮¼äµÄ¹Øϵ£ºÄÚ´æ¹ÜÀíÀûÓÃÐéÄâÎļþϵͳ֧³Ö½»»»£¬½»»»½ø³Ì(swapd)¶¨ÆÚÓɵ÷¶È³ÌÐòµ÷¶È£¬ÕâÒ²ÊÇÄÚ´æ¹ÜÀíÒÀÀµÓÚ½ø³Ìµ÷¶ÈµÄΨһÔÒò¡£µ±Ò»¸ö½ø³Ì´æÈ¡µÄÄÚ´æÓ³Éä±»»»³öʱ£¬ÄÚ´æ¹ÜÀíÏòÎļþϵͳ·¢³öÇëÇó£¬Í¬Ê±£¬¹ÒÆðµ±Ç°ÕýÔÚÔËÐеĽø³Ì¡£
³ýÁËÕâЩÒÀÀµ¹ØϵÍ⣬ÄÚºËÖеÄËùÓÐ×Óϵͳ»¹ÒªÒÀÀµÓÚһЩ¹²Í¬µÄ×ÊÔ´¡£ÕâЩ×ÊÔ´°üÀ¨ËùÓÐ×Óϵͳ¶¼Óõ½µÄ¹ý³Ì¡£ÀýÈ磺·ÖÅäºÍÊÍ·ÅÄÚ´æ¿Õ¼äµÄ¹ý³Ì£¬´òÓ¡¾¯¸æ»ò´íÎóÐÅÏ¢µÄ¹ý³Ì£¬»¹ÓÐϵͳµÄµ÷ÊÔÀý³ÌµÈµÈ¡£
ϵͳÊý¾Ý½á¹¹
ÔÚlinuxµÄÄں˵ÄʵÏÖÖУ¬ÓÐһЩÊý¾Ý½á¹¹Ê¹ÓÃƵ¶È½Ï¸ß£¬ËûÃÇÊÇ£º
task_struct.
LinuxÄÚºËÀûÓÃÒ»¸öÊý¾Ý½á¹¹£¨task_struct£©´ú±íÒ»¸ö½ø³Ì£¬´ú±í½ø³ÌµÄÊý¾Ý½á¹¹Ö¸ÕëÐγÉÁËÒ»¸ötaskÊý×é(LinuxÖУ¬ÈÎÎñºÍ½ø³ÌÊÇÏàͬµÄÊõÓï),ÕâÖÖÖ¸ÕëÊý×éÓÐʱҲ³ÆΪָÕëÏòÁ¿¡£Õâ¸öÊý×éµÄ´óСÓÉNR_TASKS(ĬÈÏΪ512)£¬±íÃ÷LinuxϵͳÖÐ×î¶àÄÜͬʱÔËÐеĽø³ÌÊýÄ¿¡£µ±½¨Á¢Ð½ø³ÌµÄʱºò£¬LinuxΪнø³Ì·ÖÅäÒ»¸ötask_struct½á¹¹£¬È»ºó½«Ö¸Õë±£´æÔÚtaskÊý×éÖС£µ÷¶È³ÌÐòһֱά»¤×ÅÒ»¸öcurrentÖ¸Õ룬ËûÖ¸Ïòµ±Ç°ÕýÔÚÔËÐеĽø³Ì¡£
Mm_struct
ÿ¸ö½ø³ÌµÄÐéÄâÄÚ´æÓÉÒ»¸ömm_struct½á¹¹À´´ú±í£¬¸Ã½á¹¹Êµ¼ÊÉÏ°üº¬Á˵±Ç°Ö´ÐÐÓ³ÏñµÄÓйØÐÅÏ¢£¬²¢ÇÒ°üº¬ÁËÒ»×éÖ¸Ïòvm_area_struct½á¹¹µÄÖ¸Õ룬vm_area_struct½á¹¹ÃèÊöÁËÐéÄâÄÚ´æµÄÒ»¸öÇøÓò¡£
Inode
ÐéÄâÎļþϵͳ(VFS)ÖеÄÎļþ¡¢Ä¿Â¼µÈ¾ùÓɶÔÓ¦µÄË÷Òý½Úµã(inode)´ú±í¡£Ã¿¸öVFSË÷Òý½ÚµãÖеÄÄÚÈÝÓÉÎļþϵͳרÊôµÄÀý³ÌÌṩ¡£VFSË÷Òý½ÚµãÖ»´æÔÚÓÚÄÚºËÄÚ´æÖУ¬Êµ¼Ê±£´æÓÚVFSµÄË÷Òý½Úµã¸ßËÙ»º´æÖС£Èç¹ûÁ½¸ö½ø³ÌÓÃÏàͬµÄ½ø³Ì´ò¿ª£¬Ôò¿ÉÒÔ¹²ÏíinadeµÄÊý¾Ý½á¹¹£¬ÕâÖÖ¹²ÏíÊÇͨ¹ýÁ½¸ö½ø³ÌÖÐÊý¾Ý¿éÖ¸ÏòÏàͬµÄinodeÍê³É¡£
LinuxµÄ¾ßÌå½á¹¹
Ëùν¾ßÌå½á¹¹ÊÇָϵͳʵÏֵĽṹ¡£
LinuxµÄ¾ßÌå½á¹¹ÀàËÆÓÚ³éÏó½á¹¹£¬ÕâÖÖ¶ÔÓ¦ÐÔÊÇÒòΪ³éÏó½á¹¹À´Ô´ÓÚ¾ßÌå½á¹¹£¬ÎÒÃǵĻ®·ÖûÓÐÑϸñÒÀÕÕÔ´´úÂëµÄĿ¼½á¹¹£¬ÇÒºÍ×ÓϵͳµÄ·Ö×éÒ²²»ÍêÈ«Æ¥Å䣬µ«ÊÇ£¬ËüºÜ½Ó½üÔ´´úÂëµÄĿ¼½á¹¹¡£
¾¡¹ÜÇ°ÃæµÄÌÖÂ۵ijéÏó½á¹¹ÏÔʾÁ˸÷¸ö×Óϵͳ֮¼äÖ»ÓкÜÉÙµÄÒÀÀµ¹Øϵ£¬µ«ÊǾßÌå½á¹¹µÄ5¸ö×Óϵͳ֮¼äÓи߶ȵÄÒÀÀµ¹Øϵ¡£ÎÒÃÇ¿ÉÒÔ¿´³ö£¬¾ßÌå½á¹¹ÖеĺܶàÒÀÀµ¹Øϵ²¢Ã»ÓÐÔÚ³éÏó½á¹¹ÖгöÏÖ¡£
LinuxÄÚºËÔ´´úÂë
Ä¿Ç°£¬½ÏжøÓÖÎȶ¨µÄÄں˰汾ÊÇ2.0.xºÍ2.2.x£¬ÒòΪ°æ±¾²»Í¬ÉÔÓвî±ð£¬Òò´ËÈç¹ûÄãÏëÈÃÒ»¸öеÄÇý¶¯³ÌÐò¼ÈÖ§³Ö2.0.x£¬ÓÖÖ§³Ö2.2.x£¬¾ÍÐèÒª¸ù¾ÝÄں˰汾½øÐÐÌõ¼þ±àÒ룬Ҫ×÷µ½ÕâÒ»µã£¬¾ÍÒªÖ§³ÖºêLINUX_VERSION_CODE,¼ÙÈçÄں˵İ汾ÓÃa.b.cÀ´±íʾ£¬Õâ¸öºêµÄÖµ¾ÍÊÇ216a+28b+c¡£ÒªÓõ½Ö¸¶¨Äں˰汾µÄÖµ£¬ÎÒÃÇ¿ÉÒÔÓÃKERNEL_VERSIONºê£¬ÎÒÃÇÒ²¿ÉÒÔ×Ô¼ºÈ¥¶¨ÒåËü¡£
¶ÔÄں˵ÄÐÞ¸ÄÓò¹¶¡ÎļþµÄ·½Ê½·¢²¼µÄ¡£PatchʵÓóÌÐòÓÃÀ´ÓÃÀ´¶ÔÄÚºËÔ´Îļþ½øÐÐһϵÁеÄÐ޸ġ£ÀýÈ磺ÄãÓÐ2.2.9µÄÔ´´úÂ룬µ«ÏëÒƵ½2.2.10¡£¾Í¿ÉÒÔ»ñµÃ2.2.10µÄ²¹¶¡Îļþ£¬Ó¦ÓÃpatchÀ´ÐÞ¸Ä2.2.9Ô´Îļþ¡£ÀýÈ磺
$ cd /usr/src/linux
$ patch pl < patch-2.2.10
Linux ÄÚºËÔ´´úÂëµÄ½á¹¹
LinuxÄÚºËÔ´´úÂëλÓÚ/usr/src/linuxĿ¼Ï¡£
/include×ÓĿ¼°üº¬Á˽¨Á¢Äں˴úÂëʱËùÐèµÄ´ó²¿·Ö°üº¬Îļþ£¬Õâ¸öÄ£¿éÀûÓÃÆäËûÄ£¿éÖؽ¨Äںˡ£
/init ×ÓĿ¼°üº¬ÁËÄں˵ijõʼ»¯´úÂ룬ÕâÊÇÄں˹¤×÷µÄ¿ªÊ¼µÄÆðµã¡£
/arch×ÓĿ¼°üº¬ÁËËùÓÐÓ²¼þ½á¹¹Ìض¨µÄÄں˴úÂë¡£È磺i386,alpha
/drivers×ÓĿ¼°üº¬ÁËÄÚºËÖÐËùÓеÄÉ豸Çý¶¯³ÌÐò£¬Èç¿éÉ豸ºÍSCSIÉ豸¡£
/fs×ÓĿ¼°üº¬ÁËËùÓеÄÎļþϵͳµÄ´úÂë¡£Èç:ext2,vfatµÈ¡£
/net×ÓĿ¼°üº¬ÁËÄں˵ÄÁ¬Íø´úÂë¡£
/mm×ÓĿ¼°üº¬ÁËËùÓÐÄÚ´æ¹ÜÀí´úÂë¡£
/ipc×ÓĿ¼°üº¬Á˽ø³Ì¼äͨÐÅ´úÂë¡£
/kernel×ÓĿ¼°üº¬ÁËÖ÷Äں˴úÂë¡£
´ÓºÎ´¦¿ªÊ¼ÔĶÁÔ´´úÂ룿
ÔÚInternet,ÓÐÈËÖÆ×÷ÁËÔ´´úÂëµ¼º½Æ÷£¬ÎªÔĶÁÔ´´úÂëÌṩÁËÁ¼ºÃµÄÌõ¼þ£¬Õ¾µãΪlxr.linux.no/source¡£
ÏÂÃæ¸ø³öÔĶÁÔ´´úÂëµÄÏßË÷:
ϵͳµÄÆô¶¯ºÍ³õʼ»¯£º
ÔÚ»ùÓÚIntelµÄϵͳÉÏ£¬µ±loadlin.exe»òLILO°ÑÄÚºË×°Èëµ½ÄÚ´æ²¢°Ñ¿ØÖÆȨ´«µÝ¸øÄÚºËʱ£¬Äں˿ªÊ¼Æô¶¯¡£¹ØÓÚÕâÒ»²¿·ÖÇë¿´£¬arch/i386/kernel/head.S,head.S½øÐÐÌض¨½á¹¹µÄÉèÖã¬È»ºóÌøתµ½init/main.cµÄmain()Àý³Ì¡£
ÄÚ´æ¹ÜÀí£º
ÄÚ´æ¹ÜÀíµÄ´úÂëÖ÷ÒªÔÚ/mm£¬µ«ÊÇÌض¨½á¹¹µÄ´úÂëÔÚarch/*/mm¡£È±Ò³Öжϴ¦ÀíµÄ´úÂëÔÚ/mm/memory.c ,¶øÄÚ´æÓ³ÉäºÍÒ³¸ßËÙ»º´æÆ÷µÄ´úÂëÔÚ/mm/filemap.c ¡£»º³åÆ÷¸ßËÙ»º´æÊÇÔÚ/mm/buffer.c ÖÐʵÏÖ£¬¶ø½»»»¸ßËÙ»º´æÊÇÔÚmm/swap_state.cºÍmm/swapfile.c¡£
Äںˣº
ÄÚºËÖУ¬Ìض¨½á¹¹µÄ´úÂëÔÚarch/*/kernel,µ÷¶È³ÌÐòÔÚkernel/sched.c,forkµÄ´úÂëÔÚkernel/fork.c,ÄÚºËÀý³Ì´¦Àí³ÌÐòÔÚinclude/linux/interrupt.h£¬task_structÊý¾Ý½á¹¹ÔÚinlucde/linux/sched.hÖС£
PCI:
PCIαÇý¶¯³ÌÐòÔÚdrivers/pci/pci.c,Æ䶨ÒåÔÚinclulde/linux/pci.h¡£Ã¿Ò»Öֽṹ¶¼ÓÐһЩÌض¨µÄPCI BIOS´úÂ룬IntelµÄÔÚarch/alpha/kernel/bios32.cÖС£
½ø³Ì¼äͨÐÅ£º
ËùÓеÄSystemVIPC¶ÔÏóȨÏÞ¶¼°üº¬ÔÚipc_permÊý¾Ý½á¹¹ÖУ¬Õâ¿ÉÒÔÔÚinclude/linux/ipc.hÖÐÕÒµ½¡£SystemVÏûÏ¢ÊÇÔÚipc/msg.cÖÐʵÏÖ¡£¹²ÏíÄÚ´æÔÚipc/shm.cÖÐʵÏÖ¡£ÐźÅÁ¿ÔÚipc/sem.cÖУ¬¹ÜµÀÔÚ/ipc/pipe.cÖÐʵÏÖ¡£
Öжϴ¦Àí£º
Äں˵ÄÖжϴ¦Àí´úÂ뼸ºõËùÓеÄ΢´¦ÀíÆ÷ÌØÓеġ£Öжϴ¦Àí´úÂëÔÚarch/i386/kernel/irq.cÖУ¬Æ䶨ÒåÔÚinclude/asm-i386/irq.hÖС£
»¨¿ª»¨°Ü2011 ÓÚ 2011-02-12 17:00:20·¢±í:
ÎÒ¶¥°¡
haoyu314 ÓÚ 2011-01-29 09:53:39·¢±í:
ѧϰÁË£¬Â¥Ö÷ÐÁ¿àÀ²£¡
nerissa ÓÚ 2010-01-08 11:30:37·¢±í:
ѧϰÁË
winskinglee ÓÚ 2009-11-05 17:37:54·¢±í:
µ«£¬²»ÊǺÜÏêϸ£¬²»¹ý»¹ÊǸÐлÁË
winskinglee ÓÚ 2009-11-05 17:34:43·¢±í:
Óе㶮
Á÷À˵ÄÅÖè ÓÚ 2009-11-03 15:34:23·¢±í:
¿ÉÒÔÔÚ×ÜÌåÉÏÁ˽âÄں˷½ÃæµÄ¹Øϵ
chambersqj ÓÚ 2009-11-02 21:57:56·¢±í:
¸ÅÀ¨µÃºÜ¾«±Ù£¡
dongch123 ÓÚ 2009-11-02 20:09:15·¢±í:
ѧϰ
ermaima ÓÚ 2009-10-19 18:43:19·¢±í:
ѧϰÁË
js001sdx ÓÚ 2009-09-29 09:18:29·¢±í:
ѧϰ
chen ÓÚ 2005-12-22 09:37:26·¢±í:
ºÃ£¬Ñ§Ï°ÁË
dfdsds ÓÚ 2005-10-30 00:14:33·¢±í:
Ö§³Ö
ccs ÓÚ 2005-09-30 00:08:48·¢±í:
ѧϰÁË