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

Linux½ø³Ì¼äͨѶ֮¹²ÏíÄÚ´æ

¹²ÏíÄÚ´æ:
ʹÓù²ÏíÄÚ´æºÍʹÓÃmalloc()À´·ÖÅäÄÚ´æÇøÓòºÜÏàËÆ¡£Ê¹Óù²ÏíÄÚ´æµÄ·½·¨ÊÇ£º
    1 ¶ÔÒ»¸ö½ø³Ì/Ïß³ÌʹÓÃshmget()·ÖÅäÄÚ´æÇøÓò¡£
    2 ʹÓÃshmat()·ÅÖÃÒ»¸ö»ò¶à¸ö½ø³Ì/Ïß³ÌÔÚ¹²ÏíÄÚ´æÖУ¬Ò²¿ÉÒÔÓÃshmctl()À´»ñÈ¡ÐÅÏ¢»òÕß¿ØÖƹ²ÏíÇøÓò¡£
    3 ʹÓÃshmdt()´Ó¹²ÏíÇøÓòÖзÖÀë¡£
    4 ʹÓÃshmctl()½â³ý·ÖÅä¿Õ¼ä
    ¹²ÏíÄÚ´æÊÇLinuxÖÐ×î¿ìËÙµÄIPC·½·¨¡£ËüÒ²ÊÇÒ»¸öË«Ïò¹ý³Ì£¬¹²ÏíÇøÓòÄÚµÄÈκνø³Ì¶¼¿ÉÒÔ¶ÁдÄÚ´æ¡£Õâ¸ö»úÖƵIJ»Àû·½ÃæÊÇÆäͬ²½ºÍЭÒ鶼²»ÊܳÌÐòÔ±¿ØÖÆ£¬±ØÐëÈ·±£½«¾ä±ú´«µÝ¸øÁË×Ó½ø³ÌºÍÏ̡߳£
Ò». º¯Êý£º shmget½éÉÜ
¹¦ÄÜ:È¡µÃ¹²ÏíÄÚ´æ¶Î
        Óï·¨:#include <sys/types.h>;
             #include <sys/ipc.h>;
             #include <sys/shm.h>;
             int shmget(key,size,shmflg)
             key_t key;
             int size,shmflg;
        ˵Ã÷:±¾ÏµÍ³µ÷Ó÷µ»ØkeyÏà¹ØµÄ¹²ÏíÄÚ´æ±êʶ·û.
             ¹²ÏíÄÚ´æ±êʶ·ûºÍÏà¹ØÊý¾Ý½á¹¹¼°ÖÁÉÙsize×ֽڵĹ²ÏíÄÚ´æ¶ÎÄÜ
             Õý³£´´½¨,ÒªÇóÒÔÏÂÊÂʵ³ÉÁ¢:
             . ²ÎÊýkeyµÈÓÚIPC_PRIVATE.
             . ²ÎÊýkeyûÓÐÏà¹ØµÄ¹²ÏíÄÚ´æ±êʶ·û,ͬʱ(shmflg&amp;IPC_CREAT)
               ֵΪÕæ.
             ¹²ÏíÄÚ´æ´´½¨Ê±,ÐÂÉú³ÉµÄ¹²ÏíÄÚ´æ±êʶÏà¹ØµÄÊý¾Ý½á¹¹±»³õʼ
         


Ïà¹ØÎĵµ£º

Linux½ø³Ì¼äͨÐÅ£º¹ÜµÀ¼°ÓÐÃû¹ÜµÀ ÊÕ²Ø

 ¹ÜµÀ¼°ÓÐÃû¹ÜµÀ
ÔÚ±¾ÏµÁÐÐòÖÐ×÷Õ߸ÅÊöÁË linux ½ø³Ì¼äͨÐŵļ¸ÖÖÖ÷ÒªÊֶΡ£ÆäÖйܵÀºÍÓÐÃû¹ÜµÀÊÇ×îÔçµÄ½ø³Ì¼äͨÐÅ»úÖÆÖ®Ò»£¬¹ÜµÀ¿ÉÓÃÓÚ¾ßÓÐÇ×Ôµ¹Øϵ½ø³Ì¼äµÄͨÐÅ£¬ÓÐÃû¹ÜµÀ¿Ë·þÁ˹ܵÀûÓÐÃû×ÖµÄÏÞÖÆ£¬Òò´Ë£¬³ý¾ßÓйܵÀËù¾ßÓеŦÄÜÍ⣬Ëü»¹ÔÊÐíÎÞÇ×Ôµ¹Øϵ½ø³Ì¼äµÄͨÐÅ¡£ ÈÏÇå¹ÜµÀºÍÓÐÃû¹ÜµÀµÄ¶Áд¹æÔòÊÇÔÚ³ÌÐòÖÐÓ¦Ó ......

linux file lock

linux file lock
linuxµÄÎļþËø·ÖΪÁ½ÖÖ£º
Ò»ÖÖÊÇadvasory lock£¬Ö»Äܱ£Ö¤½ø³ÌÄÚ¶Ôͬһ¸öÎļþËøµÄ»¥³âÓÐЧ£¬µ«ÊǶà¸ö½ø³Ì¿ÉÒÔͬʱ¶ÔÒ»¸öÎļþ¼Ó»¥³âµÄËø£¬ËùÒÔÕâÖÖËøÊǼÓÔÚfile ½á¹¹ÉÏ;Ò»ÖÖÊÇmandatory lock£¬ÕâÖÖËø¿ÉÒÔ±£Ö¤¶à¸ö½ø³ÌÎÞ·¨¶Ôͬһ¸öÎļþ¶¼¼ÓÉÏ»¥³âËø£¬ËùÒÔÕâÖÖËøÊǼÓÔÚinode ½á¹¹Éϵġ£
µ±¼Ómandatroy lockÊ ......

LinuxÖÐÈçºÎÊÍ·ÅcacheÄÚ´æ free


ÒòΪLINUX
µÄÄÚºË
»úÖÆ£¬Ò»°ãÇé¿öϲ»ÐèÒªÌØÒâÈ¥ÊÍ·ÅÒѾ­Ê¹ÓõÄcache¡£ÕâЩcacheÆðÀ´µÄÄÚÈÝ¿ÉÒÔÔö¼ÓÎļþÒÔ¼°µÄ¶ÁдËٶȡ£
ÏÈ˵ÏÂfreeÃüÁîÔõô¿´ÄÚ´æ
[root@ahsq proc]# free
total used free shared buffers cached
Mem: 515588 295452 220136 0 2060 64040
-/+ buffers/cache: 229352 286236
Swap: 682720 112 ......

Linux½ø³Ì¼äͨѶËùʹÓõÄϵͳµ÷Óú¯Êý


´°Ì嶥¶Ë
Ë÷Òý£º
1.fork¡¢execºÍexit¶ÔIPC¶ÔÏóµÄÓ°Ïì
2.fcntl¼Ç¼Ëø
3.¹ÜµÀºÍFIFOµÄÊôÐÔ
4.¹ÜµÀºÍFIFOµÄÏÞÖÆ
5.pipeº¯Êý
6.popenºÍpclose
7.mkfifoº¯Êý
8.System V IPC¹²ÐÔÃèÊö
9.msqid_ds½á¹¹
10.msggetº¯Êý
11.msgsndº¯Êý
12.msgrcvº¯Êý
13.msgctlº¯Êý
14.ÔÚSystem VÏûÏ¢¶ÓÁÐÉÏʹÓÃselectºÍpoll
15.sem ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ