Linux Ïß³ÌDetach&Join
1£®µÈ´ýÏß³Ì
pthread_join º¯ÊýÓÃÀ´µÈ´ýÒ»¸öÏ̵߳ĽáÊø£¬ÀàËÆÓÚ½ø³ÌµÄ wait º¯Êý¡£
´Ëº¯Êý½«×èÈûµ÷Óõ±Ç°Ï̵߳Ľø³Ì£¬Ö±µ½´ËÏß³ÌÍ˳ö¡£¼´Õâ¸öº¯ÊýÊÇÒ»¸öÏß³Ì×èÈûµÄº¯Êý£¬µ÷ÓÃËüµÄ½ø³Ì½«Ò»Ö±µÈ´ýµ½±»µÈ´ýµÄÏ߳̽áÊøΪ£¬µ±º¯Êý·µ»Øʱ£¬´¦ÓÚ±»µÈ´ý״̬µÄÏß³Ì×ÊÔ´±»Êջء£Èç¹ûÖ´Ðгɹ¦£¬½«·µ»Ø 0£¬Èç¹ûʧ°ÜÔò·µ»ØÒ»¸ö·Ç 0¡£´Ëº¯ÊýµÄµÚÒ»¸ö²ÎÊýΪ±»µÈ´ýµÄÏ̱߳êʶ·û£¬´ËֵΪ´´½¨Ïß³Ìʱ·µ»ØµÄÏß³Ì ID£¬´ËÏ̱߳ØÐëͬµ÷ÓÃËüµÄ½ø³ÌÏàÁªÏµ£¬¼´´´½¨¸ÃÏß³Ìʱ²»ÄÜÖ¸Ã÷´ËÏß³ÌΪ¶ÀÁ¢µÄÏ̡߳£µÚ¶þ¸ö²ÎÊýΪһ¸öÓû§¶¨ÒåµÄÖ¸Õ룬ָÏòÒ»¸ö±£´æµÈ´ýÏ̵߳ÄÍêÕûÍ˳ö״̬µÄ¾²Ì¬ÇøÓò£¬Ëü¿ÉÒÔÓÃÀ´´æ´¢±»µÈ´ýÏ̵߳ķµ»ØÖµ£¬Èç¹ûÔÚ´´½¨Ïß³Ìʱ pthread_create º¯ÊýµÄµÚ¶þ¸ö²ÎÊý__attr ÉèÖÃΪ NULL£¬Ôò´ËÍ˳öµÄ״̬ÐÅÏ¢»á¶ªÊ§¡£¹ØÓڵȴýÖ¸¶¨Ï߳̽áÊø£¬ÐèҪעÒâÒÔϼ¸µã£º
£¨1£©Ò»¸öÏß³ÌÖ»ÄܵȴýÁ¬½ÓÒ»¸öÆäËûÏ̡߳£
£¨2£©·¢²¼Á¬½Ó²Ù×÷µÄÏ̲߳»Ò»¶¨ÊdzõʼÏ̡߳£
£¨3£©Èç¹ûÓжà¸öÏ̵߳ȴýͬһÏß³ÌÖ´ÐУ¬Ö»ÓÐÒ»¸öÏß³ÌÄܹ»µÃµ½ÕýÈ·µÄ״̬ÐÅÏ¢¡£
£¨4£©ÓоºÕù¹ØϵµÄÏ̼߳äµÄÁ¬½Ó²Ù×÷½«·µ»ØÒ»¸ö´íÎó¡£
£¨5£©Èç¹ûÆô¶¯Á¬½ÓµÄÏ̱߳»È¡Ïû£¬Ôò´¦Óڵȴý״̬µÄÏ߳̿ÉÒÔ±»ÆäËûÏ̵߳ȴý¡£
£¨6£©Èç¹ûÄ¿±êÏß³ÌÔÚÖ´ÐÐ pthread_join Ç°½áÊø£¬Ôò¸Ãµ÷Óý«²»»áÒýÆðÈκÎ×èÈû²¢Á¢¼´·µ»Ø¡£
£¨7£©Ò»¸öδ±»Á¬½ÓµÄ·Ç¶ÀÁ¢Ïß³ÌÔÚÏ߳̽áÊøÇ°Ò»Ö±Õ¼ÓÃ×ÊÔ´£¬Ö±µ½´´½¨ËüµÄ½ø³Ì½áÊø¡£
pthread_joinº¯ÊýÉùÃ÷ÈçÏ£º
extern int pthread_join (pthread_t __th, void **__thread_return);
2£®·ÖÀëÏß³Ì
·ÖÀëÏß³ÌÊǵȴýµÄÄæ²Ù×÷¡£pthread_detach ¿âº¯ÊýÒÔÓû²Ù×÷µÄÏß³Ì ID ΪÆäΨһµÄ²ÎÊý¡£Èç¹ûÖ´Ðгɹ¦£¬½«Ê¹¸ÃÏß³ÌÓ뵱ǰ½ø³Ì·ÖÀ룬ʹÆä³ÉΪһ¸ö¶ÀÁ¢µÄỊ̈߳¬²¢·µ»Ø 0£¬µ± threadÖÕֹʱ£¬ÏµÍ³½«×Ô¶¯»ØÊÕËüµÄ×ÊÔ´£»Èç¹ûÖ´ÐÐʧ°Ü£¬½«²»·ÖÀëÖ¸¶¨µÄÏ̲߳¢·µ»Ø·ÇÁãÖµ¡£
pthread_detach º¯ÊýÉùÃ÷ÈçÏ£º
/* Indicate that the thread TH is never to be joined with PTHREAD_JOIN.
The resources of TH will therefore be freed immediately when it terminates, instead
of waiting for another thread to perform PTHREAD_JOIN on it. */
extern int pthread_detach (pthread_t __th) __THROW;
***********************************************
[Ô]ÔÚlinuxÖв鿴Á½¸öº¯Êý£º
find / -name pthread.h -print
cd /usr/include
grep -n 'pthread_join' ./pthread.h
grep -n 'pthread
Ïà¹ØÎĵµ£º
1.ÏÂÔØmemcached·þÎñÆ÷¶Ë°²×°Îļþ
°æ±¾£º
memcached-1.4.2.tar.gz
ÏÂÔصØÖ·£ºhttp://www.danga.com/memcached/download.bml
2.ÏÂÔØlibevent£¬memcachedÐèÒªÓõ½socked£¬ÒÀÀµ´Ë°²×°Îļþ¡£
°æ±¾£º
libevent-1.4.12-stable.tar.gz
ÏÂÔصØÖ·£ºhttp:/ ......
½Ó´¥linuxʱ¼ä»¹²»ÊǺܳ¤,ºÜ¶àÃüÁî¼Ç²»×¡,ºÇºÇ,Äõ½Ð·þÎñÆ÷¿´ÏÂÓ²ÅÌ·ÖÇø $df –lh Îļþϵͳ ÈÝÁ¿ ÒÑÓà ¿ÉÓà ÒÑÓÃ% ¹ÒÔصã
/dev/sda1 2.0G ......
su
suÃüÁîÊÇ×î»ù±¾µÄÃüÁîÖ®Ò»£¬³£ÓÃÓÚ²»Í¬Óû§¼äÇл»¡£ÀýÈ磬Èç¹ûµÇ¼Ϊ user1£¬ÒªÇл»Îªuser2£¬Ö»ÒªÓÃÈçÏÂÃüÁ
$su user2
È»ºóϵͳÌáʾÊäÈëuser2¿ÚÁÊäÈëÕýÈ·µÄ¿ÚÁîÖ®ºó¾Í¿ÉÒÔÇл»µ½user2¡£Íê³ÉÖ®ºó¾Í¿ÉÒÔÓÃexitÃüÁî·µ»Øµ½user1¡£
suÃüÁîµÄ³£¼ûÓ÷¨ÊDZä³É¸ùÓû§»ò³¬¼¶Óû§¡£Èç¹û·¢³ö²»´øÓû§ÃûµÄsuÃüÁî £¬Ôòϵ ......
Õâ´Îתµ½Á˺½¿ÕµÄÒ»¸öÏîÄ¿£¬ÐèÒªÔÚLinuxÏÂÓÃC×ö¿ª·¢¡£°æ±¾¹ÜÀí²ÉÓÃSVN£¬´Ó×òÌìÏÂÎ翪ʼÎҾͿªÊ¼ÁË°²×°£¬ÕæµÄÊÇÍ´¿àµÄ¹ý³Ì¡£ÏÖÔÚµ¹ÊÇ°²×°ºÃÁË£¬µ«ÊÇÅäÖÃÃüÁûÓÐÕÆÎÕ¡£
Èç¹ûÓÐȨÏÞ´ÓÍøÉÏÖ±½Ó¸üÐÂÈí¼þ£¬ÎÒ²»±Øÿ´Î¶¼È¥ÕÒÔ´Âë°ü£¬È ......
ÆäʵÊǸöÂù¼òµ¥µÄÎÊÌâ¡£ÔÚLDD3µÄµÚ15ÕÂÉÏÓÐд£¨¼û“Remapping Specific I/O Regions”ÕâÒ»½Ú£©¡£²»¹ýµ±Ê±×÷ÕßÑ¡ÔñÁËÒ»¸ö´íÎóµÄ×ö·¨£ºÏÈ°ÑÕâ¿éIO¿Õ¼äÓÃioremapÓ³Éäµ½ÁËÄں˿ռ䣬ȻºóÔÚÓû§½ø³Ì·ÃÎʱ»Ó³ÉäµÄµØÖ·Ëù²ú ÉúµÄȱҳÖжÏÀÓÃvmalloc_to_pageµÃµ½page£¬·µ»Ø¸øÓû§½ø³Ì¡£
È»¶ø£¬vmalloc_to_pageû·¨Óà ......