תÔØ£linux 2.6 ½ø³Ì×ܽá
תÔØ£linux 2.6 ½ø³Ì×ܽá
½ø³Ì¡¢ÇáÁ¿¼¶½ø³Ì£¨LWP£©¡¢Ïß³Ì
½ø³Ì£º³ÌÐòÖ´ÐÐÌ壬ÓÐÉúÃüÆÚ£¬ÓÃÀ´·ÖÅä×ÊÔ´µÄʵÌå
Ị̈߳º·ÖÅäCPUµÄʵÌå¡£
Óû§¿Õ¼äʵÏÖ£¬Ò»¸öÏß³Ì×èÈû£¬ËùÓж¼×èÈû¡£
ÄÚºËʵÏÖ£¬²»»áËùÓÃÏà¹ØÏ̶߳¼×èÈû¡£ÓÃLWPʵÏÖ£¬ÓÃÏß³Ì×é±íʾÕâЩÏß³ÌÂß¼ÉÏËùÊôµÄ½ø³Ì¡£
½ø³ÌÃèÊö·û
½ø³ÌÃèÊö·û£¨¼ò³Æpd, process descriptors£©£¬½á¹¹ÌåÊÇ£ºtask_struct
Êý¾Ý½Ï¶à£¬´æ·ÅÔÚkenerlµÄ¶¯Ì¬ÄÚ´æ¿Õ¼ä¡£
pdµÄÒýÓ÷ÅÔÚthread_infoÖУ¬
thread_infoÓëÄÚºËÕ»£¬·ÅÔÚÒ»¸ö8K¿Õ¼ä£¨ËüµÄµØÖ·8K¶ÔÆ룩¡£Äں˳ÌÐòʹÓõÄÕ»¿Õ¼äºÜС¡£
thread_infoÔڵײ¿£¬ÄÚºËÕ»ÔÚ¶¥²¿ÏòÏÂÔö³¤¡£
ºÃ´¦£º¶àCPUʱ·½±ã£¬Ã¿¸öCPU¸ù¾Ý×Ô¼ºµÄÕ»Ö¸Õë¾Í¿ÉÒÔÕÒµ½µ±Ç°µÄpd £¨ÒÔºóÓÃcurrent±íʾµ±Ç°CPUÔËÐеĽø³ÌÃèÊö·û£©¡£
esp(ÄÚºËÕ»Ö¸Õë)µÍ8λÖÃÁ㣬¾ÍÊÇthread_infoµØÖ·¡£
ÿ½ø³ÌÓÐ×Ô¼ºµÄthread_info, (·ÖÅäÊͷź¯Êý: alloc_thread_info, free_thread_info)
ÃèÊö·ûµÄÄÚÈÝ
Ïà¹ØµÄID £¨Ò»¸ö4ÔªËØÊý×飩
½ø³ÌID £¨PID£©
PID°´´´½¨Ë³ÐòÁ¬ÐøÔö³¤£¬µ½×î´óÖµºó´Ó×îСֵ¿ªÊ¼¡£
0ºÅ½ø³Ì£º½»»»½ø³Ì£¨swapper£©
ÓÐPID¿ÉÓÃλͼ£¬±íʾÄÇÒ»¸öPID¿ÉÓã¬ÖÁÉÙÕ¼Ò»¸öÒ³¡£
Ïß³Ì×éID£¨tgid£©£¬ÓÃLWPʵÏÖ¶àÏß³ÌÖ§³Ö
¶à½ø³Ìʱ£¬½ø³Ìid£¬¾ÍÊÇÏß³Ì×éid, Ò²¾ÍÊÇ×鳤µÄpid£¨LWP£©¡£ getpid() È¡µÄÊÇÏß³Ì×éµÄid(tgid), Ò²ÊÇ×鳤µÄpid.
µ¥Ïß³Ìʱ£¬pid = gid¡£ËùÒÔgetpid,Ò²ÊÇÕæÕýµÄpid.
½ø³Ì×éID(pgrp)¡£
»Ø»°µÄID(session).
×éID£¬¶¼ÊÇ×鳤µÄPID¡£FIXME: µ«pbÒ²Óи÷×鳤µÄPID
Ïß³Ì×鳤£ºtgid
½ø³Ì×鳤£ºsignal->pgrp £¬
»á»°³¤£ºsignal->session
¹ÜÀíIDÊý¾Ý½á¹¹——¹þÏ£±í¹ÜÀí (ÀûÓÃidÕÒµ½ËùÓÃÏà¹ØµÄpd£¬·½±ã)¡£
Ò»¸ö¹þÏ£±íÊý×é(pid_hash),´æ·ÅËĸö¹þÏ£±í£¬ ÿһ¸ö±í´ú±íÒ»Ààid (pid, tgid, pgrp, session)
ÿ¸ö¹þÏ£±íµÄÓÉÊý×飨Ë÷ÒýΪ¹þÏ£Öµ£©ºÍ¶þάÁ´±í(ǶÈëµ½½ø³ÌÃèÊö·ûÄÚµÄpidsÖÐ)ʵÏÖ
Ïà¹ØÎĵµ£º
½ø³ÌÒ»µ©µ÷ÓÃÁËwait£¬¾ÍÁ¢¼´×èÈû×Ô¼º£¬ÓÉwait×Ô¶¯·ÖÎöÊÇ·ñµ±Ç°½ø³ÌµÄij¸ö×Ó½ø³ÌÒѾÍ˳ö£¬Èç¹ûÈÃËüÕÒµ½ÁËÕâÑùÒ»¸öÒѾ±ä³É½©Ê¬µÄ×Ó½ø³Ì£¬wait ¾Í»áÊÕ¼¯Õâ¸ö×Ó½ø³ÌµÄÐÅÏ¢£¬ ²¢°ÑËü³¹µ×Ïú»Ùºó·µ»Ø£»Èç¹ûûÓÐÕÒµ½ÕâÑùÒ»¸ö×Ó½ø³Ì£¬wait¾Í»áÒ»Ö±×èÈûÔÚÕâÀֱµ½ÓÐÒ»¸ö³öÏÖΪֹ¡£
wait£¨µÈ´ý×Ó½ø³ÌÖжϻò½áÊø£©
Ïà¹Øº¯Êý waitp ......
ÕâЩ¶¼ÊǵäÐ͵ÄʹÓÃGNUµÄAUTOCONFºÍAUTOMAKE²úÉúµÄ³ÌÐòµÄ°²×°²½Öè¡£
./configureÊÇÓÃÀ´¼ì²âÄãµÄ°²×°Æ½Ì¨µÄÄ¿±êÌØÕ÷µÄ¡£±ÈÈçËü»á¼ì²âÄãÊDz»ÊÇÓÐCC»òGCC£¬²¢²»ÊÇÐèÒªCC»òGCC£¬ËüÊǸöshell½Å±¾
makeÊÇÓÃÀ´±àÒëµÄ£¬Ëü´ÓMakefileÖжÁÈ¡Ö¸ÁȻºó±àÒë¡£
make installÊÇÓÃÀ´°²×°µÄ£¬ËüÒ²´ÓMakefileÖжÁÈ¡Ö¸Á°²×°µ½Ö¸¶¨µÄÎ»Ö ......
ÎÄÕÂÀ´Ô´£ºhttp://www.ibm.com/developerworks/cn/linux/kernel/l-kn26sch/index.html
¼¶±ð£º ³õ¼¶
ÑîɳÖÞ (pubb@163.net), ¹ú·À¿Æ¼¼´óѧ¼ÆËã»úѧԺ, 2004 Äê 4 ÔÂ
2004 Äê 4 ÔÂ 01 ÈÕ
±¾ÎÄ´Ó Linux 2.4 µ÷¶ÈϵͳµÄȱÏÝÈëÊÖ£¬Ïêϸ·ÖÎöÁË Linux 2.6 µ÷¶ÈϵͳµÄÔÀíºÍʵÏÖϸ½Ú£¬²¢¶ÔÓëµ÷¶ÈϵͳÏà¹ØµÄ¸ºÔØƽºâ¡¢NUMA ½á¹¹Ò ......
×¼±¸¹¤×÷
Èç¹ûÄ㻹ûװ±àÒë»·¾³»ò×Ô¼º²»È·¶¨×°Ã»×°£¬²»·ÁÏÈÖ´ÐÐ
sudo apt-get install build-essential
Èç¹ûÄãÐèÒª±àÒë Fortran ³ÌÐò£¬ÄÇô»¹ÐèÒª°²×° gfortran(»ò g77)
sudo apt-get install gfortran
Èç¹ûÄãÒѾÁ˽âһЩ vim
µÄ֪ʶ£¬¶øÇÒÏëÓÃËüÀ´±à¼Ô´´úÂ룬ÄÇôÎÒÃDz»·Á×°¸öÍêÕû°æ
sudo apt-get install vi ......