Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

COW copy on write linux ¿ª²©À²¡£¹þ¹þ


½ñÌì¿´LinuxµÄÄÚÈÝʱÕÒµ½µÄ¡£ µ«ÔËÐÐʱ·¢ÏÖcopyʱµØÖ·ÒѾ­²»ÖµÏòͬһ¿éÄÚ´æÁË¡£ÎªÊ²Ã´ÄØ£¿£¿
STL±ê׼ģ°å¿âÖеÄstringÀ࣬ҲÊÇÒ»¸ö¾ßÓÐдʱ²Å¿½±´¼¼ÊõµÄÀà¡£C++ÔøÔÚÐÔÄÜÎÊÌâÉϱ»¹ã·ºµØÖÊÒɺÍÖ¸Ôð¹ý£¬ÎªÁËÌá¸ßÐÔÄÜ£¬STLÖеÄÐí¶àÀà¶¼²ÉÓÃÁËCopy-On-Write¼¼Êõ¡£Í¨³££¬stringÀàÖбØÓÐÒ»¸ö˽ÓгÉÔ±£¬ÆäÊÇÒ»¸öchar*£¬Óû§¼Ç¼´Ó¶ÑÉÏ·ÖÅäÄÚ´æµÄµØÖ·£¬ÆäÔÚ¹¹Ôìʱ·ÖÅäÄڴ棬ÔÚÎö¹¹Ê±ÊÍ·ÅÄÚ´æ¡£ÒòΪÊÇ´Ó¶ÑÉÏ·ÖÅäÄڴ棬ËùÒÔstringÀàÔÚά»¤Õâ¿éÄÚ´æÉÏÊǸñÍâСÐĵģ¬stringÀàÔÚ·µ»ØÕâ¿éÄÚ´æµØÖ·Ê±£¬Ö»·µ»Øconst char*£¬Ò²¾ÍÊÇÖ»¶ÁµÄ£¬Èç¹ûÄãҪд£¬ÄãÖ»ÄÜͨ¹ýstringÌṩµÄ·½·¨½øÐÐÊý¾ÝµÄ¸Äд¡£
main()
{
string str1 = "hello world";// string str1 ("hello world"); µ÷ÓõÄÊǹ¹Ô캯Êý
    string str2 = str1; // string str2 (str1); µ÷ÓõÄÊÇ¿½±´¹¹Ô캯Êý
//´Ëʱstr1,str2¹²ÏíÄÚ´æ
    printf ("Sharing the memory:\n");
    printf ("\tstr1's address: %x\n", str1.c_str() );
    printf ("\tstr2's address: %x\n", str2.c_str() );
    str1[1]='q';
    str2[1]='w';
/*µ±È»ÊÇÔÚ¹²Ïíͬһ¿éÄÚ´æµÄÀà·¢ÉúÄÚÈݸıäʱ£¬²Å»á·¢ÉúCopy-On-Write¡£±ÈÈçstringÀàµÄ[]¡¢=¡¢+=¡¢+¡¢²Ù×÷·û¸³Öµ£¬»¹ÓÐһЩstringÀàÖÐÖîÈçinsert¡¢replace¡¢appendµÈ³ÉÔ±º¯Êý¡£*/
    printf ("After Copy-On-Write:\n");
    printf ("\tstr1's address: %x\n", str1.c_str() );
    printf ("\tstr2's address: %x\n", str2.c_str() );
    return 0;
}
½á¹û£º
Sharing the memory:
        str1's address: 12ff3c //·Ç343be9£¿£¿£¿
        str2's address: 12ff14 //·Ç343be9
After Copy-On-Write:
        str1's address: 3407a9
        str2's address: 343be9
str1ºÍstr2´æ·ÅÊý¾ÝµÄµØÖ·ÊÇÒ»ÑùµÄ£¬¶øÔÚÐÞ¸ÄÄÚÈݺó£¬str1µÄµØÖ··¢ÉúÁ˱仯£¬¶østr2µÄµØÖ·»¹ÊÇÔ­À´µÄ¡£´ÓÕâ¸öÀý×Ó£¬ÎÒÃÇ¿ÉÒÔ¿´µ½stringÀàµÄCopy-On-Write¼¼Êõ¡£
ÒýÓüÆÊý¾ÍÊÇstringÀàÖÐдʱ²Å¿½±´µÄÔ­Àí£¬RefCnt±íʾʹÓù²ÏíÄÚ´æ¸ö¶ÔÏó¸öÊý¡£µ±¹²ÏíÄÚ´æ±»Ð޸ĵÄʱºò£¬²ÉÓÃÏÂÃ


Ïà¹ØÎĵµ£º

linux Ïß³ÌÓë½ø³Ì

1£®4 Ï̴߳´½¨µÄLinuxʵÏÖ
ÎÒÃÇÖªµÀ£¬LinuxµÄÏß³ÌʵÏÖÊÇÔÚºËÍâ½øÐеģ¬ºËÄÚÌṩµÄÊÇ´´½¨½ø³ÌµÄ½Ó¿Údo_fork()¡£ÄÚºËÌṩÁËÁ½¸öϵͳµ÷ÓÃ__clone()ºÍfork ()£¬×îÖÕ¶¼Óò»Í¬µÄ²ÎÊýµ÷ÓÃdo_fork()ºËÄÚAPI¡£µ±È»£¬ÒªÏëʵÏÖỊ̈߳¬Ã»ÓкËÐÄ¶Ô¶à½ø³Ì£¨ÆäʵÊÇÇáÁ¿¼¶½ø³Ì£©¹²ÏíÊý¾Ý¶ÎµÄÖ§³ÖÊDz»Ðеģ¬Òò´Ë£¬do_fork()ÌṩÁ˺ ......

linuxÏÂrar½âѹ(rarlinuxÏÂÔØ£¬°²×° £¬Ê¹ÓÃ)

 linuxÏÂÏë½âѹrarÎļþ ±ØÐë°²×°Èí¼þ£¬ÎÒʹÓõ½ÊÇrarlinux  
ÏÂÃæÊÇÏÂÔØµØÖ·
rarlinux¹Ù·½ÍøÕ¾ÏÂÔØµØÖ·
http://www.rarsoft.com/download.htm
°²×°                                  ......

linuxϰ²×°oracle 10gʱlibXp.so.6½â¾ö·½·¨

°²×°¹ý³ÌÖгöÏÖ“X11/extensions/Print.h: No such file or directory”µÄ½â¾ö·½·¨
ÕâÊÇÒòΪϵͳÖÐȱÉÙlibXp-devel
# yum install libXp-devel
°²×°¹ý³ÌÖгöÏÖ“X11/bitmaps/gray: No such file or directory”µÄ½â¾ö·½·¨
ÕâÊÇÒòΪϵͳÖÐȱÉÙxorg-x11-xbitmaps£¨x11/xbitmaps (Ubuntu) and xorg-x1 ......

linux telnetµÇ½ÂýÎÊÌâ

 ¸ü¸Ä/etc/resolv.confÎļþ
    Èç¹ûÄãµÄlinuxÖ÷»úÖ»ÊÇÔÚ¾ÖÓòÍøÄÚ¹¤×÷£¬Ç뽫nameserverµØÖ·¸ÄÎªÍø¿¨±¾ÉíµÄµØÖ·¡£
    Àý£º
    # vi /etc/resolv.conf
    nameserver 192.168.0.160
    search site
    È»ºó ......

Linux Ì×½Ó×Ö±à³ÌÖÐµÄ 5 ¸öÒþ»¼

 
Linux Ì×½Ó×Ö±à³ÌÖÐµÄ 5 ¸öÒþ»¼
ÔÚÒì¹¹»·¾³Öпª·¢¿É¿¿µÄÍøÂçÓ¦ÓóÌÐò
¼¶±ð£º Öм¶
M. Tim Jones
(mtj@mtjones.com
), ×ÊÉîÈí¼þ¹¤³Ìʦ, Emulex
2005 Äê 10 ÔÂ 08 ÈÕ
Socket API ÊÇÍøÂçÓ¦ÓóÌÐò¿ª·¢ÖÐʵ¼ÊÓ¦Óõıê×¼ API¡£¾¡¹Ü¸Ã API ¼òµ¥£¬µ«ÊÇ¿ª·¢ÐÂÊÖ¿ÉÄܻᾭÀúһЩ³£¼ûµÄÎÊÌâ¡£±¾ÎÄʶ±ðһЩ×î³£¼ûµÄÒþ» ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ