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

¹ØÓÚforkÎÒµÄÒ»µãÌå»á£¬Ï£Íû¶Ô´ËÈÔÓÐÃÔ»óµÄÈËÓÐËùÆôʾ

·¢²¼Ê±¼ä:2007-10-22 17:58:30À´Ô´:ºìÁª×÷Õß:gxf
ÏàÐÅÔںܶàLINUXÏÂѧCÓïÑÔµÄÈËÔÚѧ½ø³ÌµÄʱºò¶Ôfork×ÜÓе㲻Ã÷°×£¬Æäʵ×î¹Ø¼üµÄÊÇÒªÀí½âforkÖ®ºóµ½µ×·¢ÉúÁËʲô¡£

ÒýÓÃ:
µ±Ò»¸ö½ø³Ìµ÷ÓÃÁËforkÒÔºó,ϵͳ»á´´½¨Ò»¸ö×Ó½ø³Ì.Õâ¸ö×Ó½ø³ÌºÍ¸¸½ø³Ì²»Í¬µÄµØ·½Ö»ÓÐËûµÄ½ø³ÌIDºÍ¸¸½ø³ÌID²»Í¬,ÆäËûµÄ¶¼ÊÇÒ»Ñù.¾ÍÏó½ø³Ì¿Ë¡(clone)×Ô¼ºÒ»Ñù.Ò»µ©×Ó½ø³Ì±»´´½¨,¸¸×Ó½ø³ÌÒ»Æð´Ófork´¦¼ÌÐøÖ´ÐÐ,Ï໥¾ºÕùϵͳµÄ×ÊÔ´£¬Àí½âÕâµã·Ç³£ÖØÒª¡£ÕâÀïÓÖ¿ÉÒÔÌÖÂÛ¹ØÓÚ½ø³Ì×èÈûµÄÎÊÌ⣬ÕâÀï¾Í²»ÏêϸÌÖÂÛÁË¡£


µ±È»´´½¨Á½¸öһģһÑùµÄ½ø³ÌÊÇûÓÐÒâÒåµÄ.ΪÁËÇø·Ö¸¸½ø³ÌºÍ×Ó½ø³Ì,ÎÒÃDZØÐë¸ú×ÙforkµÄ·µ»ØÖµ. µ±forkµôÓÃʧ°ÜµÄʱºò(ÄÚ´æ²»×ã»òÕßÊÇÓû§µÄ×î´ó½ø³ÌÊýÒѵ½)fork·µ»Ø-1,·ñÔòforkµÄ·µ»ØÖµÓÐÖØÒªµÄ×÷ÓÃ.

¶ÔÓÚ¸¸½ø³Ìfork·µ»Ø×Ó½ø³ÌµÄID,¶ø¶ÔÓÚ×Ó½ø³Ìfork·µ»Ø0.Õâ¾ÍÊÇΪʲô˵forkµ÷ÓÃÒ»´Î¶ø·µ»Ø2´Î¡£ÕâÀïÉæ¼°µ½ÏµÍ³¶Ô½ø³ÌµÄµ÷¶ÈËã·¨µÄ²»Í¬Ôì³ÉCPUʱ¼äƬ·ÖÅäµÄ²»È·¶¨ÐÔ£¬¸¸×Ó½ø³Ì»á½øÐÐ×ÊÔ´¾ºÕù£¬Òò¶øforkµ÷ÓÃÒ»´Î¶ø·µ»Ø2´ÎÒ²ÊDZØÒªµÄ¡£ÎÒÃÇÒ²ÊǸù¾ÝÕâ¸ö·µ»ØÖµÀ´Çø·Ö¸¸×Ó½ø³ÌµÄ.

±¾ÆªËãÊÇÅ×שÒýÓñ£¬»¶Ó­ÅúÆÀÖ¸Õý£¡

[ ±¾Ìû×îºóÓÉ gxf ÓÚ 2007-10-22 18:01 ±à¼­ ]
ÎÄÕÂÆÀÂÛ

¹²ÓÐ 3 ÌõÆÀÂÛ

  1. qwdzq ÓÚ 2008-03-13 12:11:07·¢±í:

    ÒªÊÇÄܾٸö¼òµ¥µÄÀý×ӾͺÃÁË

  2. gxf ÓÚ 2007-10-22 22:20:00·¢±í:

    ºÇºÇ£¬È·ÊµÆ¤Ã«µÄ¸ÅÄîÎÊÌâ¡£¼ÌÐøѧϰ£¬×î½üѧУ¸ÕºÃÔÚÉϲÙ×÷ϵͳ

    Ô­ÀíµÄ¿Î³Ì£¬ÎҵüÓÓÍÁË¡£Ï£Íû¡°beautiful ¡±´ó¸ç¶à¶àÖ¸½Ì

    [ ±¾Ìû×îºóÓÉ gxf ÓÚ 2007-10-22 22:35 ±à¼­ ]

  3. beautiful ÓÚ 2007-10-22 20:26:09·¢±í:

    СС¶®Ò»µã£¬²»¹ýÊǸÅÄµÄ