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

LinuxÏß³Ìpthread±Ê¼Ç


ÔÚÔĶÁNginxµÄ´úÂë.ÏÈÅöµ½µÄÊÇÏ̲߳¿·ÖµÄ
ÒòΪ´Ómain¿ªÊ¼×îÔçÊÇ×öÏ̲߳¿·ÖµÄ¹¤×÷
ʵϰһÏÂpthread·½ÃæµÄÄÚÈÝ
#include "pthread.h"
#include "stdio.h"
void* thread_test(void* ptr)
{
        while(1)
        printf("i am child pthread\n");
}
int main()
{
        pthread_t tid;
        pthread_create(&tid, NULL, thread_test, NULL);
        while(1)
        printf("i am main pthread\n");
        return 0;
}
Õâ¶Î´úÂëÊÇ´Ó±ðÈËÕâÀïÕÒµ½µÄ.²»¹ý°Ñµ±ÖеÄbugÐÞÕýÁË
±àÒëÃüÁîÐÐ
./gcc -lpthread -o pthread ./pthread.c
¼ÇסÐèÒª¼Ó-lpthread²ÎÊý,·ñÔòpthreadµÄÏà¹Øº¯Êý»á±¨¸æ˵ÕÒ²»µ½
¹ØÓÚpthread_createº¯Êý
ÓÐÈËÌáµ½Ëû´´½¨µÄ×ÓÏ̻߳ñÈ¡µ½µÄpidºÍÖ÷Ï̵߳IJ»Ò»ÖÂ
ÕâÊÇÓÉÓÚÔçÆÚÄں˰汾ÖеÄʵÏÖ²»Í¬.ÓÉÓÚpthreadÖ»ÊÇʹÓÃÇáÁ¿½ø³ÌȥģÄâÏß³Ì
ÔçÆÚµÄpthreadʵÏÖÊÇlinuxthread¿â,ÿ¸öÇáÁ¿½ø³Ì»á±»ÏÔʾÔÚps½ø³ÌÁбíÖÐ
¶ø×îеÄpthreadʵÏÖÊÇNPTL,ËùÓÐÇáÁ¿½ø³ÌÔÚ½ø³ÌÁбíÖÐÖ»±íÏÖΪÖ÷Ï̵߳ÄPIDºÅ.
Æäʵÿ¸öÏ̵߳ÄpidÊDz»Í¬µÄ.µ«ÊÇpthread¿âÈÃͨ¹ýpthread_create´´½¨µÄÏ̵߳ÄpidÓëÖ÷pidÒ»Ö¶øÒÑ.
¼ÈȻÿ¸ö½ø³Ì¶¼ÓжÀÁ¢µÄ½ø³Ì,ÄÇôʵ¼ÊµÄÏ̵߳Ľø³ÌºÅÔÚÄÄÀï¿ÉÒÔ¿´µ½ÄØ?
¾­¹ýÊÔÑé
ÎÒ·¢ÏÖÔÚ/proc/[PID]/taskĿ¼ÏÂ
±£´æÓд˽ø³ÌËùÓеÄpthreadµÄʵ¼Ê½ø³ÌºÅ
ÀýÈçÉÏÃæµÄÀý³Ì,µ±ÎÒÃÇÖ´ÐÐÖ®ºó
ÎÒÃÇÔÚpsÖп´µ½µÄ½ø³ÌºÅÈç¹ûÊÇ20632
ÄÇô½øÈë/proc/20632/task
ÎÒÃÇ¿ÉÒÔ¿´µ½ÓÐ20632ÒÔ¼°20633Á½¸öpid
Æäʵ20633¾ÍÊǵڶþ¸ö´´½¨³öÀ´µÄÇáÁ¿½ø³Ì
¸ù¾ÝPOSIXµÄÒªÇó
ÎÒÃÇɱµôÈκÎÒ»¸öÏß³Ì,Æäʵ¶¼»á°ÑSIGNO·¢Ë͵½ËùÓеÄÏß³ÌÖÐ.
ËùÒÔÎÒÃÇÈç¹ûÖ´ÐÐkill -9 20633
ÆäʵÄã»á·¢ÏÖÕû¸ö³ÌÐò¶¼Í˳öÁË
ÏÂÃæÎÒ°ÑPOSIX¶ÔÏß³ÌʵÏÖµÄÒªÇóÌù³öÀ´(Õⲿ·Ö²Î¿¼ÁËlinuxÏß³ÌdzÎö)
1, ²é¿´½ø³ÌÁбíµÄʱºò, Ïà¹ØµÄÒ»×étask_structÓ¦µ±±»Õ¹ÏÖΪÁбíÖеÄÒ»¸ö½Úµã;
2, ·¢Ë͸øÕâ¸ö”½ø³Ì”µÄÐźÅ(¶ÔÓ¦killϵͳµ÷ÓÃ), ½«±»¶ÔÓ¦µÄÕâÒ»×étask_structËù¹²Ïí, ²¢ÇÒ±»ÆäÖеÄÈÎÒâÒ»¸ö”Ï߳̔´¦Àí;
3, ·¢Ë͸øij¸ö”Ï߳̔µÄÐźÅ(¶ÔÓ¦pthread_kill), ½«Ö»±»¶ÔÓ¦µÄÒ»¸ötask_struct½ÓÊÕ, ²¢ÇÒÓÉËü×Ô¼ºÀ´´¦Àí;
4, µ±”½ø³Ì&r


Ïà¹ØÎĵµ£º

LinuxÉ豸ģÐÍÖ®input×ÓϵͳÏê½â

Ò»£ºÇ°ÑÔ
×î½üÔÚÑо¿androidµÄsensor driver£¬Ö÷ÒªÊÇE-compass£¬ÆäÖÐÓõ½ÁËLinux input×Óϵͳ.ÔÚÍøÉÏÒ²¿´Á˺ܶàÕâ·½ÃæµÄ×ÊÁÏ£¬¸Ð¾õ»¹ÊÇÕâƪ·ÖÎöµÄ±È½ÏϸÖÂ͸³¹£¬Òò´ËתÔØÒ»ÏÂÒÔ±ã×Ô¼ºÑ§Ï°£¬Í¬Ê±ºÍ´ó¼Ò·ÖÏí£¡
£¨Õâƪ²©¿ÍÖ÷ÒªÊÇÒÔ¼üÅÌÇý¶¯ÎªÀýµÄ£¬²»¹ý½²½âµÄÊÇLinux Input Subsystem£¬¿ÉÒÔ×ÐϸµÄÑо¿Ò»Ï£¡£©
¼üÅÌÇý¶¯½«¼ì ......

linux·þÎñÆ÷Òì³£¹ÊÕϽâ¾öÒ»Àý

·þÎñÆ÷ͻȻ³öÏÖ¹«ÍøÍøÂ粻ͨ¡£»¹ºÃÓÐÅäÁ½¸öIP£¬Ò»¹«Íø£¬Ò»ÄÚÍø£¬ÄÚÍø¿Éͨ£¬Í¨¹ýÄÚÍøÁ¬½Óµ½·þÎñÆ÷ÉÏ ¡£²é¿´ÈÕÖ¾£¬dmesg£¬·¢ÏÖÓÐÕâÑùÒ»Ìõ£º
Sep  9 14:34:36 slave kernel: NETDEV WATCHDOG: eth0: transmit timed out
/etc/init.d/network restart ÍøÂç·þÎñÖØÆôһϣ¬»Ö¸´Õý³£¡£
µ½google²éÕÒ×ÊÁÏ£¬·¢ÏÖÒ²ÓÐÒ»ÑùµÄÎÊ ......

linuxÏ mysql Íü¼ÇrootÓû§ÃÜÂë½â¾ö°ì·¨

linuxÏÂÍü¼ÇÁËmysqlµÄrootÓû§ÃÜÂë½â¾ö°ì·¨£º
¡¡¡¡Ò»¡¢ÒÔϵͳµÄrootÓû§£¨Ê²Ã´£¬ÄãµÄϵͳµÄrootÓû§ÃÜÂëÒ²ÍüÁË¡£ÄÇÖ»ºÃ¿´ÎÒÁíÍâһƪlinuxÏÂÍü¼ÇrootÓû§µÄ½â¾ö°ì·¨ÁËÏȽâ¾öÕâ¸öÎÊÌ⣩µÇ½ϵͳ£¬½øÈëÖÕ¶Ë
¡¡¡¡[root@localhost /]#
¡¡¡¡¶þ¡¢É±µômysql½ø³Ì
¡¡¡¡·½·¨1¡¢[root@localhost /]#killall mysqld
¡¡¡¡·½·¨2¡ ......

Linux USB gadgetÉ豸Çý¶¯½âÎö

Ò»¡¢±³¾°ÖªÊ¶
    1¡¢USB Mass StorageÀà¹æ·¶¸ÅÊö
       USB ×éÖ¯ÔÚuniversal Serial Bus Mass Storage Class Spaceification 1.1°æ±¾Öж¨ÒåÁ˺£Á¿´æ´¢É豸ÀࣨMass Storage Class£©µÄ¹æ·¶£¬Õâ¸öÀà¹æ·¶°üÀ¨Ëĸö
        ¶ÀÁ¢µÄ×ÓÀ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ