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

LinuxÏÂthread±à³Ì£¨Èý£©

×÷ÕߣºSam£¨Õç·å£© sam_cdoe@hotmail.com
1.´´½¨thread.
int pthread_create(pthread_t *restrict thread, const pthread_attr_t *restrict attr,
              void *(*start_routine)(void*), void *restrict arg);
²ÎÊý1£ºpthread_t *restrict thread£º´´½¨threadµÄthread ID.
²ÎÊý2£ºconst pthread_attr_t *restrict attr£º´´½¨Ï̵߳ÄÊôÐÔ¡£
²ÎÊý3£ºvoid *(*start_routine)(void*)£ºthread·þÎñ³ÌÐò¡£
²ÎÊý4£ºvoid *restrict arg£ºthread·þÎñ³ÌÐò²ÎÊý¡£
2. µÈ´ýÄ¿±êÏß³ÌÖÕÖ¹£º
pthread_join() º¯Êý»áÒ»Ö±×èÈûµ÷ÓÃỊ̈߳¬Ö±µ½Ö¸¶¨µÄÏß³ÌÖÕÖ¹¡£
Ö¸¶¨µÄÏ̱߳ØÐëλÓÚµ±Ç°µÄ½ø³ÌÖУ¬¶øÇÒ²»µÃÊÇ·ÖÀëÏ̡߳£ËùÓд´½¨Ê±ÊôÐÔΪPTHREAD_CREATE_JOINABLEµÄ·Ç·ÖÀëthread. ×îÖÕ¶¼ÐèÒªµ÷ÓÃpthread_join() or pthread_detach() ¡£ÕâÑùthreadËùÕ¼×ÊÔ´ºÍ Thread ID ²Å±»ÊÍ·Å¡£
3. ·ÖÀëthread:
int pthread_detach(pthread_t thread);
pthread_detach()Ö¸³öµ±thread ½áÊøʱ£¬threadËùÕ¼×ÊÔ´ºÍThread ID»á±»ÊͷźÍÔÙÀûÓá£Èç¹ûµ÷ÓÃpthread_detach()ʱ£¬threadûÓнáÊø£¬Ëü²¢²»»áµ¼ÖÂthreadÍ˳ö¡£ËüÖ»¶ÔPTHREAD_CREATE_JOINABLE ·Ç·ÖÀëthreadÓÐЧ¡£
4. »ñÈ¡thread ID:
pthread_t pthread_self(void)£»
·µ»Øµ÷ÓÃthreadµÄthread ID.
5. ±È½Ïthread ID:
int pthread_equal(pthread_t t1, pthread_t t2);Èç¹û tid1 ºÍ tid2 ÏàµÈ£¬pthread_equal() ½«·µ»Ø·ÇÁãÖµ£¬·ñÔò½«·µ»ØÁã¡£
6. Ïòthread·¢Ðźţº
int pthread_kill(pthread_t thread, int sig);
tid ËùÖ¸¶¨µÄÏ̱߳ØÐëÓëµ÷ÓÃÏß³ÌÔÚͬһ¸ö½ø³ÌÖС£sig ²ÎÊý±ØÐëÀ´×Ô signal(5) ÌṩµÄÁÐ±í¡£
7. Í˳öỊ̈߳º
void pthread_exit(void *value_ptr);
pthread_exit()ÓÃÀ´ÖÕÖ¹µ÷ÓÃthread²¢ÖÃλvalue_ptr.Õâ¸öÖµ»á½»¸øpthread_join¡£
ThreadµÄÈ¡Ïû£º
ͬһ½ø³ÌÄÚ£¬Ä³¸öThread¿ÉÒÔÏòÆäËüthread·¢ËÍÈ¡ÏûÒªÇó£¬ÒªÇóÄ¿±êthreadÍ˳öÔËÐС£
È¡ÏûÇëÇóµÄ´¦Àí·½Ê½È¡¾öÓÚÄ¿±êÏ̵߳Ä״̬¡£×´Ì¬ÓÉÒÔÏÂÁ½¸öº¯ÊýÈ·¶¨£ºpthread_setcancelstate() ºÍ pthread_setcanceltype()¡£
 pthread_setcancelstate() ÆôÓûò½ûÓÃÏß³ÌÈ¡Ïû¹¦ÄÜ¡£´´½¨Ïß³Ìʱ£¬È±Ê¡Çé¿öÏÂÏß³ÌÈ¡Ïû¹¦ÄÜ´¦ÓÚÆôÓÃ״̬¡£
pthread_setcanceltype() ¿ÉÒÔ½«È¡ÏûÀàÐÍÉèÖÃΪÑÓ³Ù»òÒ첽ģʽ¡£´´½¨Ïß³Ìʱ£¬È±Ê¡Çé¿öÏ»ὫȡÏûÀàÐÍÉèÖÃΪÑÓ³Ùģʽ¡£ÔÚÑÓ³ÙģʽÏ£¬Ö»ÄÜÔÚÈ¡ÏûµãÈ¡ÏûÏ̡߳£ÔÚÒì


Ïà¹ØÎĵµ£º

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

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

ʵսLinux Bluetooth±à³Ì(Áù) L2CAP±à³ÌʵÀý

ÀýÒ»£º·¢ËÍSignaling Packet£º
Signaling CommandÊÇ2¸öBluetoothʵÌåÖ®¼äµÄL2CAP²ãÃüÁî´«Êä¡£ËùÒÔµÃSignaling CommandʹÓÃCID 0x0001.
¶à¸öCommand¿ÉÒÔÔÚÒ»¸öC-frame£¨control frame£©Öз¢ËÍ¡£
 Èç¹ûÒªÖ±½Ó·¢ËÍSignaling Command.ÐèÒª½¨Á¢SOCK_RAWÀàÐ͵ÄL2CAPÁ¬½ÓSocket¡£ÕâÑù²ÅÓлú»á×Ô¼ºÌî³äCommand Code£¬Identi ......

ÈçºÎÔÚlinuxϹۿ´Ðèvodplayer²¥·ÅµÄµçÓ°

ÆäʵÕâ¸öÒ²¿ÉÒÔÊÓΪÏÂÔØÐèÒªvodplayer»òÕß½Ð×ö±¦Àûͨ²¥·ÅÆ÷²ÅÄܹۿ´µÄÔÚÏßµçÓ°µÄÒ»¸ö½â¾ö·½°¸¡£
±¦ÀöͨÊÓƵµã²¥·þÎñÓÃÔÚÐí¶à¿í´ø·þÎñÉÏ¡£ËٶȽϿ죬µ«ÊDZØÐëʹÓÃÆäÌض¨µÄ²¥·ÅÆ÷vodplayer²ÅÄܲ¥·Å¡£¶øÕâ¸öÈí¼þÖ»ÓÐwindowsƽ̨Éϵİ汾¡£ÔÚlinux»òÕßmacÎÞ·¨Ê¹Óᣳý·Ç×°ÐéÄâ»ú¡£ÄÇÌ«Âé·³¡£
ÏÖÔÚÌṩһ¸ö½â¾ö·½°¸£¬ÆäÔ­ÀíÈçÏ ......

ÐÞ¸´Linuxϵͳ

ÐÞ¸´Linuxϵͳ
1£®Ê¹Óü±¾ÈÅÌ×é½øÐÐά»¤
¼±¾ÈÅÌ×飨Ҳ³ÆΪboot/rootÅÌ×飩£¬ÊÇϵͳ¹ÜÀíÔ±±Ø²»¿ÉÉٵŤ¾ß¡£ÓÃËü¿ÉÒÔ¶ÀÁ¢µØÆô¶¯ºÍÔËÐÐÒ»¸öÍêÕûµÄLinuxϵͳ¡£Êµ¼Ê ÉÏ£¬¼±¾ÈÅÌ×éÖеĵÚ2ÕÅÅÌÉϾÍÓÐÒ»¸öÍêÕûµÄLinuxϵͳ£¬°üÀ¨rootÎļþϵͳ£»¶øµÚ1ÕÅÅÌÔò´æ·ÅÁË¿ÉÆô¶¯µÄÄںˡ£
ʹÓü±¾ÈÅÌ×éά»¤ÏµÍ³ºÜ¼òµ¥¡£Ö»ÐèÓÃÕâÁ½ÕÅÅÌÆô¶ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ