LinuxÖÐfork()ÈçºÎʵÏÖ¸¸×Ó½ø³Ì²»Í¬µÄ·µ»ØÖµ
ÍøÉϹØÓÚfork()ÎÄÕ¶¼Ëµfork()À´´´½¨×Ó½ø³Ì,ÀûÓ÷µ»ØÖµµÄ²»Í¬À´Ö´Ðв»Í¬µÄ´úÂð¶Î.µ«¶¼Ã»ÓÐ˵µ½ÈçºÎʵÏÖ²»Í¬µÄ·µ»ØÖµ.ÏÂÃæÎÒ½«ºÍÄãÀ´ËµËµÕâ¸öÎÊ題:
¿¼ÂÇÈçÏ´úÂë:
int i = fork();
if ( i )
{
......
}
else
{
........
}
.......
µ±¸¸½ø³ÌÖ´Ðе½ÕâÒ»¾äʱ:int i = fork(),¾Í´´½¨ÁËÒ»¸öеĽø³Ì,еĽø³ÌÓÐ×Ô¼ºµÄ¶ÑÕ»¶ÎºÍ´úÂë¶Î,µ«ÊǺ͸¸½ø³Ì¹²Ïí´úÂë¶Î.×îÐèÒªÖ÷ÒâµÄÊÇ,
×Ó½ø³ÌµÄÉÏÏÂÎÄÒ²ºÍ¸¸½ø³ÌÏàͬ,Õâ¾ÍÊÇ˵,´Ëʱ,¸¸½ø³ÌµÄ PCÖ¸Ïòint i = fork(),×Ó½ø³ÌµÄ PCÒ²Ö¸Ïòint i = fork().µ«ÊÇ,˶¼ÖªµÀ,µ±Ç°PCÖ¸ÏòµÄÕâ¸öÓï¾äÊǺÊýµ÷ÓÃ,¼´È»ÊǺÊýµ÷ÓÃ,¾ÍÓзµ»ØÖµ,·µ»ØÖµ·ÅÔÚÄÄÀïÄØ?¾ÍÊÇ·ÅÔÚ½ø³ÌµÄ¸÷×Ô¶ÑÕ»ÖÐ.ËùÒÔÔÚ¸¸½ø³Ìµ÷ÓÃfork()ʱ,fork()ºÊýÔÚ¸¸½ø³ÌµÄ¶ÑÕ»ÖÐдÈë×Ó½ø³ÌµÄ½ø³ÌID,¶øÓÖÔÚ¸Õ¸Õ´´½¨µÄ×Ó½ø³ÌµÄ¶ÑÕ»ÖÐдÈë0.fork()ºÊýµ÷ÓýáÊøºó,ÒòΪÓÐеĽø³Ì,ËùÒÔϵͳҪÖØе÷¶È,¾ÍÔÚÕâÒ»¿Ì,¸¸×Ó½ø³ÌµÄPCÖ¸Ïòfork()ºÊý·µ»Ø´¦,Èç¹û¸¸½ø³ÌµÃµ½ÔËÐÐ,Ôò¸¸½ø³Ì´Ó×Ô¼ºµÄ¶ÑÕ»Öеõ½µÄ·µ»ØÖµÊÇ×Ó½ø³ÌµÄID,´Ó¶ø i = ID;Èç¹û×Ó½ø³ÌµÃµ½ÔËÐÐ,Ôò×Ó½ø³Ì´Ó×Ô¼ºµÄ¶ÑÕ»Öеõ½µÄ·µ»ØÖµÊÇ0,¼´ i = 0.
ÓÖ¿¼ÂÇÒÔÏ´úÂë:
int i = fork();
.......
int j = fork();
Ïà¹ØÎĵµ£º
mkdirÃüÁî
¹¦ÄÜ£º´´½¨Ò»¸öĿ¼£¨ÀàËÆMSDOSϵÄmdÃüÁ¡£
Óï·¨£ºmkdir [Ñ¡Ïî] dir-name
˵Ã÷£º¸ÃÃüÁî´´½¨ÓÉdir-nameÃüÃûµÄĿ¼¡£ÒªÇó´´½¨Ä¿Â¼µÄÓû§ÔÚµ±Ç°Ä¿Â¼ÖУ¨dir-nameµÄ¸¸Ä¿Â¼ÖУ©¾ßÓÐдȨÏÞ£¬²¢ÇÒdirname²»ÄÜÊǵ±Ç°Ä¿Â¼ÖÐÒÑÓеÄĿ¼»ò ÎļþÃû³Æ¡£
ÃüÁîÖи÷Ñ¡ÏîµÄº¬ÒåΪ£º
- m ¶Ôн¨Ä¿Â¼ÉèÖôæȡȨÏÞ¡£Ò²¿ÉÒÔÓà ......
/etc/hostsÒ»¶¨ÒªÓÐÑϸñµÄ¸ñʽ!!!
grid control 10.2.0.1.1°²×°×¢ÒâÊÂÏî
1.hostname
ÍøÂ磺
¾¡Á¿Ê¹Óþ²Ì¬IP£¬/etc/hostsµÄÎļþ¸ñʽºÜÖØÒª£¬²»ÖªµÀÊǸöBUG»¹ÊÇÒªÇó¾ÍÊÇÄÇôÑϸñ¡£ÎÒÒ»¿ªÊ¼¾ÍÊÇÔÚÕâ³ÔµÄ¿÷£¬ÔÚprecheckÐèÇóµÄʱºòºöÂÔÁË/etc/hosts¼ì²éʧ°ÜµÄ´íÎ󣬽á¹û°²×°Èí¼þûÎÊÌ⣬µ«ÅäÖõÄʱºò³ö´í ......
Linux select()Ïê½â selectϵͳµ÷ÓÃÊÇÓÃÀ´ÈÃÎÒÃǵijÌÐò¼àÊÓ¶à¸öÎļþ¾ä±ú(file descriptor)µÄ״̬±ä»¯µÄ¡£³ÌÐò»áÍ£ÔÚselectÕâÀïµÈ´ý£¬Ö±µ½±»¼àÊÓµÄÎļþ¾ä±úÓÐijһ¸ö»ò¶à¸ö·¢ÉúÁË״̬¸Ä±ä¡£ ÎļþÔÚ¾ä±úÔÚLinuxÀïºÜ¶à£¬Èç¹ûÄãmanij¸öº¯Êý£¬ÔÚº¯Êý·µ»ØÖµ²¿·Ö˵µ½³É¹¦ºóÓÐÒ»¸öÎļþ¾ä±ú±»´´½¨µÄ¶¼Êǵģ¬Èçman socket¿ÉÒÔ¿´µ½&ldqu ......
1. װϵͳ
ÎÒ×°µÄ˫ϵͳ£¬Windows 7 ºÍ Fedora 12.
1£©ÎÒµÄCÅÌÓÐ50GB£¬ËùÒÔÎÒÏÈ·ÖÁËÇø£¬·Ö³É3¸ö£¬1¸ö30GB£¬1¸ö15GB£¬Ê£ÏµÄÒ»¸öÇø3GB¡£
2£©ÏÈ×°Windows 7ÔÚ30GBµÄ·ÖÇø¡£
P£ºSonyµÄÐͺÅVGN-NR120EºÜ±ä̬£¬°²×°µÄʱºò±ØÐëÒªÓÃ×îв¹¶¡µÄ°²×°Å̲ſÉÒÔÇý¶¯µ½Ó²ÅÌ£¨µ¼Ö²»ÄÜ×°XP£©£¬¿ÉÄÜÊÇHDD ......
±à¼gedit /etc/fstab:
//192.168.1.1/winshare /mnt/share defaults,auto,username=windowsÓû§Ãû, password=windowsÃÜÂë 0 0
±¸×¢£º
£¨1£©ÖÕ¶ËÃüÁîÐйÒÔØ£ºmount //192.168.1.1/winshare /mnt/share -o user=windowsÓû§Ãû%windowsÃÜÂë
£¨2£©etc/rc.d/rcÔò¸ù¾ÝÆä²ÎÊýÖ¸¶¨µÄÔËÐÐģʽ(ÔËÐ춱ð£¬ÔÚinittabÎļþÖпÉÒÔÉèÖ ......