LinuxÄں˵Äͬ²½»úÖÆ
Ò»¡¢ÒýÑÔ
ÔÚÏÖ´ú²Ù×÷ϵͳÀͬһʱ¼ä¿ÉÄÜÓжà¸öÄÚºËÖ´ÐÐÁ÷ÔÚÖ´ÐУ¬Òò´ËÄÚºËÆäʵÏó¶à½ø³Ì¶àÏ̱߳à³ÌÒ»ÑùÒ²ÐèҪһЩͬ²½»úÖÆÀ´Í¬²½¸÷Ö´Ðе¥Ôª¶Ô¹²ÏíÊý¾ÝµÄ·ÃÎÊ¡£ÓÈÆäÊÇÔڶദÀíÆ÷ϵͳÉÏ£¬¸üÐèҪһЩͬ²½»úÖÆÀ´Í¬²½²»Í¬´¦ÀíÆ÷ÉϵÄÖ´Ðе¥Ôª¶Ô¹²ÏíµÄÊý¾ÝµÄ·ÃÎÊ¡£
ÔÚÖ÷Á÷µÄLinuxÄÚºËÖаüº¬Á˼¸ºõËùÓÐÏÖ´úµÄ²Ù×÷ϵͳ¾ßÓеÄͬ²½»úÖÆ£¬ÕâЩͬ²½»úÖÆ°üÀ¨£ºÔ×Ó²Ù×÷¡¢ÐźÅÁ¿£¨semaphore£©¡¢¶ÁдÐźÅÁ¿£¨rw_semaphore£©¡¢spinlock¡¢BKL(Big Kernel Lock)¡¢rwlock¡¢brlock£¨Ö»°üº¬ÔÚ2.4ÄÚºËÖУ©¡¢RCU£¨Ö»°üº¬ÔÚ2.6ÄÚºËÖУ©ºÍseqlock£¨Ö»°üº¬ÔÚ2.6ÄÚºËÖУ©¡£
¶þ¡¢Ô×Ó²Ù×÷
ËùνÔ×Ó²Ù×÷£¬¾ÍÊǸòÙ×÷¾ø²»»áÔÚÖ´ÐÐÍê±ÏÇ°±»ÈκÎÆäËûÈÎÎñ»òʼþ´ò¶Ï£¬Ò²¾Í˵£¬ËüµÄ×îСµÄÖ´Ðе¥Î»£¬²»¿ÉÄÜÓбÈËü¸üСµÄÖ´Ðе¥Î»£¬Òò´ËÕâÀïµÄÔ×Óʵ¼ÊÊÇʹÓÃÁËÎïÀíѧÀïµÄÎïÖÊ΢Á£µÄ¸ÅÄî¡£
Ô×Ó²Ù×÷ÐèÒªÓ²¼þµÄÖ§³Ö£¬Òò´ËÊǼܹ¹Ïà¹ØµÄ£¬ÆäAPIºÍÔ×ÓÀàÐ͵Ķ¨Ò嶼¶¨ÒåÔÚÄÚºËÔ´ÂëÊ÷µÄinclude/asm/atomic.hÎļþÖУ¬ËüÃǶ¼Ê¹Óûã±àÓïÑÔʵÏÖ£¬ÒòΪCÓïÑÔ²¢²»ÄÜʵÏÖÕâÑùµÄ²Ù×÷¡£
Ô×Ó²Ù×÷Ö÷ÒªÓÃÓÚʵÏÖ×ÊÔ´¼ÆÊý£¬ºÜ¶àÒýÓüÆÊý(refcnt)¾ÍÊÇͨ¹ýÔ×Ó²Ù×÷ʵÏֵġ£Ô×ÓÀàÐͶ¨ÒåÈçÏ£º
typedef struct { volatile int counter; } atomic_t;
volatileÐÞÊÎ×ֶθæËßgcc²»Òª¶Ô¸ÃÀàÐ͵ÄÊý¾Ý×öÓÅ»¯´¦Àí£¬¶ÔËüµÄ·ÃÎʶ¼ÊǶÔÄÚ´æµÄ·ÃÎÊ£¬¶ø²»ÊǶԼĴæÆ÷µÄ·ÃÎÊ¡£
Ô×Ó²Ù×÷API°üÀ¨£º
atomic_read(atomic_t * v);
¸Ãº¯Êý¶ÔÔ×ÓÀàÐ͵ıäÁ¿½øÐÐÔ×Ó¶Á²Ù×÷£¬Ëü·µ»ØÔ×ÓÀàÐ͵ıäÁ¿vµÄÖµ¡£
atomic_set(atomic_t * v, int i);
¸Ãº¯ÊýÉèÖÃÔ×ÓÀàÐ͵ıäÁ¿vµÄֵΪi¡£
void atomic_add(int i, atomic_t *v);
¸Ãº¯Êý¸øÔ×ÓÀàÐ͵ıäÁ¿vÔö¼ÓÖµi¡£
atomic_sub(int i, atomic_t *v);
¸Ãº¯Êý´ÓÔ×ÓÀàÐ͵ıäÁ¿vÖмõÈ¥i¡£
int atomic_sub_and_test(int i, atomic_t *v);
¸Ãº¯Êý´ÓÔ×ÓÀàÐ͵ıäÁ¿vÖмõÈ¥i£¬²¢ÅжϽá¹ûÊÇ·ñΪ0£¬Èç¹ûΪ0£¬·µ»ØÕ棬·ñÔò·µ»Ø¼Ù¡£
void atomic_inc(atomic_t *v);
¸Ãº¯Êý¶ÔÔ×ÓÀàÐͱäÁ¿vÔ×ÓµØÔö¼Ó1¡£
void atomic_dec(atomic_t *v);
¸Ãº¯Êý¶ÔÔ×ÓÀàÐ͵ıäÁ¿vÔ×ӵؼõ1¡£
int atomic_dec_and_test(atomic_t *v);
¸Ãº¯Êý¶ÔÔ×ÓÀàÐ͵ıäÁ¿vÔ×ӵؼõ1£¬²¢ÅжϽá¹ûÊÇ·ñΪ0£¬Èç¹ûΪ0£¬·µ»ØÕ棬·ñÔò·µ»Ø¼Ù¡£
int atomic_inc_and_test(atomic_t *v);
¸Ãº¯Êý¶ÔÔ×ÓÀàÐ͵ıäÁ¿vÔ×ÓµØÔö¼Ó1£¬²¢ÅжϽá¹ûÊÇ·ñΪ0£¬Èç¹ûΪ0£¬·µ»ØÕ棬·ñÔò·µ»Ø¼Ù¡£
int atomic_add_negative(int i, atomic_t *v);
¸
Ïà¹ØÎĵµ£º
£¨L2CAPÐÒé¼ò½é£¬L2CAPÔÚBlueZÖеÄʵÏÖÒÔ¼°L2CAP±à³Ì½Ó¿Ú£©
Ò»£ºL2CAPÐÒé¼ò½é£º
Logical Link Control and Adaptation Protocol(L2CAP)
Âß¼Á¬½Ó¿ØÖƺÍÊÊÅäÐÒé (L2CAP) ΪÉϲãÐÒéÌṩÃæÏòÁ¬½ÓºÍÎÞÁ¬½ÓµÄÊý¾Ý·þÎñ£¬²¢Ìṩ¶àÐÒ鹦ÄܺͷָîÖØ×é²Ù×÷¡£L2CAP ³äÐíÉϲãÐÒéºÍÓ¦ÓÃÈí¼þ´«ÊäºÍ½ÓÊÕ×î´ó³¤¶ÈΪ 64K µÄ 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±»ÈÏΪÊÇÒ»¸ö±È½Ï°²È«µÄInternet·þÎñÆ÷£¬×÷ΪһÖÖ¿ª·ÅÔ´´úÂë²Ù×÷ϵͳ£¬Ò»µ©LinuxϵͳÖз¢ÏÖÓа²È«Â©¶´£¬InternetÉÏÀ´×ÔÊÀ½ç¸÷µØµÄÖ¾Ô¸Õß»áÓ»Ô¾ÐÞ²¹Ëü¡£È»¶ø£¬ÏµÍ³¹ÜÀíÔ±ÍùÍù²»Äܼ°Ê±µØµÃµ½ÐÅÏ¢²¢½øÐиüÕý£¬Õâ¾Í¸øºÚ¿ÍÒԿɳËÖ®»ú¡£Ïà¶ÔÓÚÕâ ......
from:×ÞöεÄרÀ¸
ʲôʱºòÐèÒª´´½¨Ï̳߳ØÄØ£¿¼òµ¥µÄ˵£¬Èç¹ûÒ»¸öÓ¦ÓÃÐèҪƵ·±µÄ´´½¨ºÍÏú»ÙỊ̈߳¬¶øÈÎÎñÖ´ÐеÄʱ¼äÓַdz£¶Ì£¬ÕâÑùÏ̴߳´½¨ºÍÏú»ÙµÄ´øÀ´µÄ¿ªÏú¾Í²»ÈݺöÊÓ£¬ÕâʱҲÊÇÏ̳߳ظóö³¡µÄ»ú»áÁË¡£Èç¹ûÏ̴߳´½¨ºÍÏú»Ùʱ¼äÏà±ÈÈÎÎñÖ´ÐÐʱ¼ä¿ÉÒÔºöÂÔ²»¼Æ£¬ÔòûÓбØҪʹÓÃÏ̳߳ØÁË¡£
&n ......
µÚ20Õ LinuxÄÚºËÒÆÖ²
Èí¼þÒÆÖ²µÄ¸ÅÄî¼òµ¥µØ˵¾ÍÊÇÈÃÒ»Ì×Èí¼þÔÚÖ¸¶¨µÄÓ²¼þƽ̨ÉÏÕý³£ÔËÐС£ÒÆÖ²ÖÁÉÙ°üÀ¨ÁËÁ½¸ö²»Í¬µÄÓ²¼þ»òÕßÈí¼þƽ̨¡£¶ÔÓÚÓ¦ÓÃÈí¼þÀ´Ëµ£¬ÒÆÖ²Ö÷Òª¿¼ÂDzÙ×÷ϵͳµÄ²îÒ죬ÖصãÔÚÐÞ¸Äϵͳµ÷Óᣱ¾ÕµÄÖصãÊÇLinuxÄÚºËÒÆÖ²£¬ÐèÒª¿¼ÂÇÓ²¼þƽ̨µÄ²îÒ죬Éæ¼°½Ï¶à֪ʶ¡£Ö÷ÒªÄÚÈÝÈçÏ£º
q ......