LinuxÄں˵ÄÁ´±í
×Ô2.1Äں˿ª·¢°æÒÔÀ´£¬linux¾ÍÒýÈëÁËÕýʽµÄÁ´±íʵÏÖ,²ÉÓõÄÊÇË«ÏòÑ»·Á´±í¡£Òò´Ë£¬ÔÚ¿ª·¢¹ý³ÌÖÐÓ¦¸ÃʹÓÃÕâЩÒÑÓеĽӿڡ£
1. ¶¨Òå
Á´±í½á¹¹Ì嶨ÒåÔÚÎļþ<linux/list.h>ÖС£
struct list£ßhead {
struct list_head *next;
struct list_head *prev;
};
ʹÓÃʱͨ³£ÐèÒª°ÑËüǶÈëµ½Äã×Ô¼ºµÄ½á¹¹ÌåÖС£
Àý£º
struct my_struct {
struct list_head list;
unsigned long dog;
void * cat;
};
ÏÂÃæ¸ø³öһЩ½Ó¿Ú£º
struct my_struct *p;
³õʼ»¯£º
/*¶¯Ì¬³õʼ»¯*/
p->dog = 0;
p->cat = NULL;
INIT_LIST_HEAD(&p->list);
/*¾²Ì¬³õʼ»¯*/
struct my_struct mine = {
.list = LIST_HDAD_INIT(mine.list);
.dog = 0;
.cat = NULL;
};
/*Ö±½ÓÉùÃ÷²¢³õʼ»¯*/
static LIST_HEAD(fox); /*ÉùÃ÷²¢³õʼ»¯Ò»¸öÃûΪfoxµÄ¾²Ì¬Á´±í*/
2. »ù±¾²Ù×÷
¸øÁ´±íÔö¼ÓÒ»¸ö½Úµã£º
list_add(struct list_head *new, struct list_head *head);
/*¸Ãº¯ÊýÏòÖ¸¶¨Á´±íµÄhead½Úµãºó²åÈënew½Úµã¡£*/
list_add_tail(struct list_head *new, struct list_head *head);
/*¸Ãº¯ÊýÏòÖ¸¶¨Á´±íµÄhead½Úµãǰ²åÈënew½Úµã¡£*/
´ÓÁ´±íÖÐɾ³ýÒ»¸ö½Úµã£º
list_del(struct list_head *entry);
/*¸Ãº¯Êý½ö½öÊǽ«entryÔªËØ´ÓÁ´±íÖÐÒÆ×ß¡£*/
list_del_init(struct list_head *entry);
/*¸Ãº¯Êý½«entryÔªËØ´ÓÁ´±íÖÐÒÆ×ß²¢Ôٴγ
Ïà¹ØÎĵµ£º
1. HCI²ãÐÒé¸ÅÊö£º
HCIÌṩһÌ×ͳһµÄ·½·¨À´·ÃÎÊBluetoothµ×²ã¡£ÈçͼËùʾ£º
´ÓͼÉÏ¿ÉÒÔ¿´³ö£¬Host Controller Interface(HCI) ¾ÍÊÇÓÃÀ´¹µÍ¨HostºÍModule¡£Hostͨ³£¾ÍÊÇPC£¬ ModuleÔòÊÇÒÔ¸÷ÖÖÎïÀíÁ¬½ÓÐÎʽ£¨USB,serial,pc-cardµÈ£©Á¬½Óµ½PCÉϵÄbluetooth Dongle¡£
ÔÚHostÕâÒ»¶Ë£ºapplication,SDP,L2capµÈÐÒé ......
Chapter 1: Thread
¢Ù thread functions
1. pthread_self();
2. thread existing
you can get the value of rval_ptr just by pthread_join(pthread_t tht, void ** rval_ptr)
cancel a thread as the thread exits with PTHREAD_CANCELED in pthread_exit, this functio ......
¡¡±¾ÎÄÖÜÏêµÄ½éÉÜÁËLinuxÄÚºËÖеÄͬ²½»úÖÆ£ºÔ×Ó²Ù×÷¡¢ÐźÅÁ¿¡¢¶ÁдÐźÅÁ¿ºÍ×ÔÐýËøµÄAPI£¬Ê¹ÓÃÐèÇó¼°Ò»Ð©µäÐÍʾÀý
¡¡¡¡Ò»¡¢ÒýÑÔ
¡¡¡¡ÔÚÏÖ´ú²Ù×÷ϵͳÀͬһʱ¼ä¿ÉÄÜÓжà¸öÄÚºËÖ´ÐÐÁ÷ÔÚÖ´ÐУ¬Òò´ËÄÚºËÆäʵÏó¶à½ø³Ì¶àÏ̱߳à³ÌÏàͬҲÐèҪһЩͬ²½»úÖÆÀ´Í¬²½¸÷Ö´Ðе¥Ôª¶Ô¹²ÏíÊý¾ÝµÄ·ÃÎÊ¡£ÓÈÆäÊÇÔÚ¶à´¦ÀíÆ÷ϵͳÉÏ£¬¸üÐèÒªÒ» ......
¹²Ïí¿â
½éÉܹ²Ïí¿â
Linux ϵͳÉÏÓÐÁ½Àà¸ù±¾²»Í¬µÄ Linux ¿ÉÖ´ÐгÌÐò¡£µÚÒ»ÀàÊǾ²Ì¬Á´½ÓµÄ¿ÉÖ´ÐгÌÐò¡£¾²Ì¬¿ÉÖ´ÐгÌÐò°üº¬Ö´ÐÐËùÐèµÄËùÓк¯Êý — »»¾ä»°Ëµ£¬ËüÃÇÊÇ“ÍêÕûµÄ”¡£ÒòΪÕâÒ»ÔÒò£¬¾²Ì¬¿ÉÖ´ÐгÌÐò²»ÒÀÀµÈκÎÍⲿ¿â¾Í¿ÉÒÔÔËÐС£
µÚ¶þÀàÊǶ¯Ì¬Á´½ÓµÄ¿ÉÖ´ÐгÌÐò¡£
¾²Ì¬¿ÉÖ´ÐгÌÐòÓ붯 ......