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

LinuxÏÂthread±à³Ì£¨¶þ£©

×÷Õߣº Sam£¨Õç·å£© sam_code@hotmail.com
threadÊôÐÔ£º
pthread_create()ÖУ¬µÚ¶þ¸ö²ÎÊý£¨pthread_attr_t£©Îª½«Òª´´½¨µÄthreadÊôÐÔ¡£Í¨³£Çé¿öÏÂÅäÖÃΪNULL£¬Ê¹ÓÃȱʡÉèÖþͿÉÒÔÁË¡£
µ«Á˽âÕâЩÊôÐÔ£¬ÓÐÀûÓÚ¸üºÃµÄÀí½âthread.
ÊôÐÔ¶ÔÏó£¨pthread_attr_t£©ÊDz»Í¸Ã÷µÄ£¬¶øÇÒ²»ÄÜͨ¹ý¸³ÖµÖ±½Ó½øÐÐÐ޸ġ£ÏµÍ³ÌṩÁËÒ»×麯Êý£¬ÓÃÓÚ³õʼ»¯¡¢ÅäÖúÍÏú»ÙÿÖÖ¶ÔÏóÀàÐÍ¡£
´´½¨ÊôÐÔ£º
int pthread_attr_init(pthread_attr_t *attr);
´´½¨µÄÊôÐÔÉ趨ΪȱʡÉèÖá£
Ïú»ÙÊôÐÔ£º
int pthread_attr_destroy(pthread_attr_t *attr);
Ò»£ºÉèÖ÷ÖÀë״̬£º
Ï̵߳ķÖÀë״̬ÓÐ2ÖÖ£ºPTHREAD_CREATE_JOINABLE£¨·Ç·ÖÀë״̬£©£¬ PTHREAD_CREATE_DETACHED£¨·ÖÀë״̬£©
·ÖÀë״̬º¬ÒåÈçÏ£º
Èç¹ûʹÓà PTHREAD_CREATE_JOINABLE ´´½¨·Ç·ÖÀëỊ̈߳¬Ôò¼ÙÉèÓ¦ÓóÌÐò½«µÈ´ýÏß³ÌÍê³É¡£Ò²¾ÍÊÇ˵£¬³ÌÐò½«¶ÔÏß³ÌÖ´ÐÐ pthread_join¡£ ·Ç·ÖÀëÏß³ÌÔÚÖÕÖ¹ºó£¬±ØÐëÒªÓÐÒ»¸öÏß³ÌÓà join À´µÈ´ýËü¡£·ñÔò£¬²»»áÊͷŸÃÏ̵߳Ä×ÊÔ´ÒÔ¹©ÐÂÏß³ÌʹÓ㬶øÕâͨ³£»áµ¼ÖÂÄÚ´æй©¡£Òò´Ë£¬Èç¹û²»Ï£ÍûÏ̱߳»µÈ´ý£¬Ç뽫¸ÃÏß³Ì×÷Ϊ·ÖÀëÏß³ÌÀ´´´½¨¡£
Èç¹ûʹÓà PTHREAD_CREATE_DETACHED ´´½¨·ÖÀëthread,Ôò±íÃ÷´ËthreadÔÚÍ˳öʱ»á×Ô¶¯»ØÊÕ×ÊÔ´ºÍthread ID.
Sam֮ǰºÜϲ»¶Ê¹Ó÷ÖÀëthread. µ«ÏÖÔÚÂýÂýʹÓÃÖоõµÃÕâÑùÊǸö²»ºÃµÄÏ°¹ß¡£ÒòΪ·ÖÀëthreadÓиöÎÊÌ⣺Ö÷³ÌÐòÍ˳öʱ£¬ºÜÄÑÈ·ÈÏ×ÓthreadÒѾ­Í˳ö¡£Ö»ºÃʹÓÃÈ«¾Ö±äÁ¿À´±êÃ÷×ÓthreadÒѾ­Õý³£Í˳öÁË¡£
ÁíÍ⣺²»¹Ü´´½¨·ÖÀ뻹ÊÇ·Ç·ÖÀëµÄthread.ÔÚ×ÓthreadÈ«²¿Í˳ö֮ǰÍ˳öÖ÷³ÌÐò¶¼ÊǺÜÓзçÏյġ£Èç¹ûÖ÷thread Ñ¡Ôñreturn,»òÕßµ÷ÓÃexit()Í˳ö£¬ÔòËùÓÐthread¶¼»á±»killµô¡£ÕâÑùºÜÈÝÒ׳ö´í¡£SamÉϴγöµÄÎÊÌâÆäʵ¾ÍÊÇÕâ¸ö¡£µ«Èç¹ûÖ÷threadÖ»Êǵ÷ÓÃpthread_exit().Ôò½öÖ÷Ï̱߳¾ÉíÖÕÖ¹¡£½ø³Ì¼°½ø³ÌÄÚµÄÆäËûÏ߳̽«¼ÌÐø´æÔÚ¡£ËùÓÐÏ̶߳¼ÒÑÖÕֹʱ£¬½ø³ÌÒ²½«ÖÕÖ¹¡£
int pthread_attr_getdetachstate(const pthread_attr_t *attr,int *detachstate);
int pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate);
µÃµ½µ±Ç°ºÍ·ÖÀë״̬ºÍÉèÖõ±Ç°µÄ·ÖÀë״̬¡£
¶þ£ºÉèÖÃÕ»Òç³ö±£»¤Çø´óС:
Õ»Òç³ö¸ÅÄ
Òç³ö±£»¤¿ÉÄܻᵼÖÂϵͳ×ÊÔ´ÀË·Ñ¡£Èç¹ûÓ¦ÓóÌÐò´´½¨´óÁ¿Ị̈߳¬²¢ÇÒÒÑÖªÕâЩÏß³ÌÓÀÔ¶²»»áÒç³öÆäÕ»£¬Ôò¿ÉÒԹرÕÒç³ö±£»¤Çø¡£Í¨¹ý¹Ø±ÕÒç³ö±£»¤Çø£¬¿ÉÒÔ½Úʡϵͳ×ÊÔ´¡£
Ïß³ÌÔÚÕ»ÉÏ·ÖÅä´óÐÍÊý¾Ý½á¹¹Ê±£¬¿ÉÄÜÐèÒª½Ï´óµÄÒç³ö±£»¤ÇøÀ´¼ì²âÕ»Òç³ö¡£
int pthre


Ïà¹ØÎĵµ£º

ʵսLinux Bluetooth±à³Ì£¨ËÄ£© L2CAP²ã±à³Ì

£¨L2CAPЭÒé¼ò½é£¬L2CAPÔÚBlueZÖеÄʵÏÖÒÔ¼°L2CAP±à³Ì½Ó¿Ú£©
Ò»£ºL2CAPЭÒé¼ò½é£º
Logical Link Control and Adaptation Protocol(L2CAP)
Âß¼­Á¬½Ó¿ØÖƺÍÊÊÅäЭÒé (L2CAP) ΪÉϲãЭÒéÌṩÃæÏòÁ¬½ÓºÍÎÞÁ¬½ÓµÄÊý¾Ý·þÎñ£¬²¢Ìṩ¶àЭÒ鹦ÄܺͷָîÖØ×é²Ù×÷¡£L2CAP ³äÐíÉϲãЭÒéºÍÓ¦ÓÃÈí¼þ´«ÊäºÍ½ÓÊÕ×î´ó³¤¶ÈΪ 64K µÄ L2CAP Ê ......

LinuxÏÂc³ÌÐò¿ª·¢±Ê¼Ç

 µÚÒ»ÕÂ
1.
½âÊÍÐÔÓïÑÔ£ºshell  javascript python  ±à³ÌÈËÔ±²»ÐèÒª¾­¹ý±àÒë Á¬½ÓµÄ¹ý³Ì£¬¿ÉÒÔÔÚÌض¨»·¾³ÏÂÖ±½ÓÖ´ÐеÄÓïÑÔ  ×Ô¶¯±àÒëÁ¬½Ó¡£¿ª·¢Ð§Âʸߣ¬µ«ÔËÐÐЧÂʵ͡£
±àÒëÐÍÓïÑÔ£ºjava c c++£¬ÐèÒª¾­¹ý±à³ÌÈËÔ±¾­¹ý±àÒëºÍÁ¬½Ó²úÉú¿ÉÖ´ÐгÌÐòµÄÓïÑÔ¡£ÔËÐÐЧÂʸߡ£
2.
Êý¾Ý
Êý¾Ý½á¹¹£ºÊý¾ÝÖ®¼äµÄ ......

linuxÏÂgdbµ¥²½µ÷ÊÔ

 
Óà GDB µ÷ÊÔ³ÌÐò
GDB ¸ÅÊö
————
GDB ÊÇ GNU ¿ªÔ´×éÖ¯·¢²¼µÄÒ»¸öÇ¿´óµÄ UNIX ϵijÌÐòµ÷ÊÔ¹¤¾ß¡£»òÐí£¬¸÷λ±È½Ïϲ»¶ÄÇÖÖͼÐνçÃ淽ʽµÄ£¬Ïñ VC ¡¢ BCB µÈ IDE µÄµ÷ÊÔ£¬µ«Èç¹ûÄãÊÇÔÚ UNIX ƽ̨ÏÂ×öÈí¼þ£¬Äã»á·¢ÏÖ GDB Õâ¸öµ÷ÊÔ¹¤¾ßÓÐ±È VC ¡¢ BCB µÄͼÐλ¯µ÷ÊÔÆ÷¸üÇ¿´óµÄ¹¦ÄÜ¡£Ëùν ¡° ......

Linux Ϲصôij¸ö¶Ë¿Ú

 ÔÚÅäÖÃApache James Mail Server µÄʱºò£¬Linux ĬÈÏÕ¼ÓÃÁË25ºÅ¶Ë¿Ú£¬ÐèÒª°ÑËü¹Øµô²ÅÄÜÔËÐÐJames Mail Server¡£
nmap localhost : ²é¿´Õ¼ÓõĶ˿ڡ£
ÓÉÓÚ·þÎñÊÇÓÉÊØ»¤½ø³Ìά»¤£¬ËùÒÔ ÕÒµ½¸Ã·þÎñµÄPID£¬È»ºókillµô¾ÍOKÁË¡£
netstat -anep | grep 25
tcp        0  & ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ