Linux»·¾³½ø³Ì¼äͨÐÅ
linuxϽø³Ì¼äͨÐŵļ¸ÖÖÖ÷ÒªÊֶμò½é£º
¹ÜµÀ£¨Pipe£©¼°ÓÐÃû¹ÜµÀ£¨named pipe£©£º¹ÜµÀ¿ÉÓÃÓÚ¾ßÓÐÇ×Ôµ¹Øϵ½ø³Ì¼äµÄͨÐÅ£¬ÓÐÃû¹ÜµÀ¿Ë·þÁ˹ܵÀûÓÐÃû×ÖµÄÏÞÖÆ£¬Òò´Ë£¬³ý¾ßÓйܵÀËù¾ßÓеŦÄÜÍ⣬Ëü»¹ÔÊÐíÎÞÇ×Ôµ¹Øϵ½ø³Ì¼äµÄͨÐÅ£»
Ðźţ¨Signal£©£ºÐźÅÊDZȽϸ´ÔÓµÄͨÐÅ·½Ê½£¬ÓÃÓÚ֪ͨ½ÓÊܽø³ÌÓÐijÖÖʼþ·¢Éú£¬³ýÁËÓÃÓÚ½ø³Ì¼äͨÐÅÍ⣬½ø³Ì»¹¿ÉÒÔ·¢ËÍÐźŸø½ø³Ì±¾Éí£»linux³ýÁËÖ§³ÖUnixÔçÆÚÐźÅÓïÒ庯ÊýsigalÍ⣬»¹Ö§³ÖÓïÒå·ûºÏPosix.1±ê×¼µÄÐźź¯Êýsigaction£¨Êµ¼ÊÉÏ£¬¸Ãº¯ÊýÊÇ»ùÓÚBSDµÄ£¬BSDΪÁËʵÏÖ¿É¿¿ÐźŻúÖÆ£¬ÓÖÄܹ»Í³Ò»¶ÔÍâ½Ó¿Ú£¬ÓÃsigactionº¯ÊýÖØÐÂʵÏÖÁËsignalº¯Êý£©£»
±¨ÎÄ£¨Message£©¶ÓÁУ¨ÏûÏ¢¶ÓÁУ©£ºÏûÏ¢¶ÓÁÐÊÇÏûÏ¢µÄÁ´½Ó±í£¬°üÀ¨PosixÏûÏ¢¶ÓÁÐsystem VÏûÏ¢¶ÓÁС£ÓÐ×㹻ȨÏ޵Ľø³Ì¿ÉÒÔÏò¶ÓÁÐÖÐÌí¼ÓÏûÏ¢£¬±»¸³Óè¶ÁȨÏ޵Ľø³ÌÔò¿ÉÒÔ¶Á×߶ÓÁÐÖеÄÏûÏ¢¡£ÏûÏ¢¶ÓÁп˷þÁËÐźųÐÔØÐÅÏ¢Á¿ÉÙ£¬¹ÜµÀÖ»ÄܳÐÔØÎÞ¸ñʽ×Ö½ÚÁ÷ÒÔ¼°»º³åÇø´óСÊÜÏÞµÈȱµã¡£
¹²ÏíÄڴ棺ʹµÃ¶à¸ö½ø³Ì¿ÉÒÔ·ÃÎÊͬһ¿éÄÚ´æ¿Õ¼ä£¬ÊÇ×î¿ìµÄ¿ÉÓÃIPCÐÎʽ¡£ÊÇÕë¶ÔÆäËûͨÐÅ»úÖÆÔËÐÐЧÂʽϵͶøÉè¼ÆµÄ¡£ÍùÍùÓëÆäËüͨÐÅ»úÖÆ£¬ÈçÐźÅÁ¿½áºÏʹÓã¬À´´ïµ½½ø³Ì¼äµÄͬ²½¼°»¥³â¡£
ÐźÅÁ¿£¨semaphore£©£ºÖ÷Òª×÷Ϊ½ø³Ì¼äÒÔ¼°Í¬Ò»½ø³Ì²»Í¬Ïß³ÌÖ®¼äµÄͬ²½ÊֶΡ£
Ì×½Ó¿Ú£¨Socket£©£º¸üΪһ°ãµÄ½ø³Ì¼äͨÐÅ»úÖÆ£¬¿ÉÓÃÓÚ²»Í¬»úÆ÷Ö®¼äµÄ½ø³Ì¼äͨÐÅ¡£Æð³õÊÇÓÉUnixϵͳµÄBSD·ÖÖ§¿ª·¢³öÀ´µÄ£¬µ«ÏÖÔÚÒ»°ã¿ÉÒÔÒÆÖ²µ½ÆäËüÀàUnixϵͳÉÏ£ºLinuxºÍSystem VµÄ±äÖÖ¶¼Ö§³ÖÌ×½Ó×Ö¡£
Ò» ¹ÜµÀºÍFIFO £¨pipes£©
1 ¹ÜµÀµÄ¹Ø¼ü¸ÅÄî
¹ÜµÀÊÇ°ëË«¹¤µÄ£¬Êý¾ÝÖ»ÄÜÏòÒ»¸ö·½ÏòÁ÷¶¯£»ÐèҪ˫·½Í¨ÐÅʱ£¬ÐèÒª½¨Á¢ÆðÁ½¸ö¹ÜµÀ£»
(ÔÚÒ»¸ö¸¸×Ó½ø³ÌÏ໥ͨÐŵĹý³ÌÖУ¬Êµ¼ÊÉÏÊÇ´ò¿ªÁËÁ½¸ö¹ÜµÀ)
Ö»ÄÜÓÃÓÚ¸¸×Ó½ø³Ì»òÕßÐֵܽø³ÌÖ®¼ä£¨¾ßÓÐÇ×Ôµ¹ØϵµÄ½ø³Ì£©£»
µ¥¶À¹¹³ÉÒ»ÖÖ¶ÀÁ¢µÄÎļþϵͳ£º¹ÜµÀ¶ÔÓڹܵÀÁ½¶ËµÄ½ø³Ì¶øÑÔ£¬¾ÍÊÇÒ»¸öÎļþ£¬µ«Ëü²»ÊÇÆÕͨµÄÎļþ£¬Ëü²»ÊôÓÚijÖÖÎļþϵͳ£¬¶øÊÇ×ÔÁ¢ÃÅ»§£¬µ¥¶À¹¹³ÉÒ»ÖÖÎļþϵͳ£¬²¢ÇÒÖ»´æÔÚÓëÄÚ´æÖС£
Êý¾ÝµÄ¶Á³öºÍдÈ룺һ¸ö½ø³ÌÏò¹ÜµÀÖÐдµÄÄÚÈݱ»¹ÜµÀÁíÒ»¶ËµÄ½ø³Ì¶Á³ö¡£Ð´ÈëµÄÄÚÈÝÿ´Î¶¼Ìí¼ÓÔڹܵÀ»º³åÇøµÄĩ⣬²¢ÇÒÿ´Î¶¼ÊÇ´Ó»º³åÇøµÄÍ·²¿¶Á³öÊý¾Ý¡£
2 FIFOµÄ¹Ø¼ü¸ÅÄî
¹ÜµÀÓ¦ÓõÄÒ»¸öÖØ´óÏÞÖÆÊÇËüûÓÐÃû×Ö£¬Òò´Ë£¬Ö»ÄÜÓÃÓÚ¾ßÓÐÇ×Ôµ¹ØϵµÄ½ø³Ì¼äͨÐÅ£¬ÔÚÓÐÃû¹ÜµÀ£¨named pipe»òFIFO£©Ìá³öºó£¬¸ÃÏÞÖƵõ½ÁË¿Ë·þ¡£FIFO²»Í¬ÓڹܵÀÖ®´¦ÔÚÓÚËüÌṩһ¸ö·¾¶ÃûÓëÖ®¹ØÁª£¬ÒÔFIFOµÄÎ
Ïà¹ØÎĵµ£º
1. HCI²ãÐÒé¸ÅÊö£º
HCIÌṩһÌ×ͳһµÄ·½·¨À´·ÃÎÊBluetoothµ×²ã¡£ÈçͼËùʾ£º
´ÓͼÉÏ¿ÉÒÔ¿´³ö£¬Host Controller Interface(HCI) ¾ÍÊÇÓÃÀ´¹µÍ¨HostºÍModule¡£Hostͨ³£¾ÍÊÇPC£¬ ModuleÔòÊÇÒÔ¸÷ÖÖÎïÀíÁ¬½ÓÐÎʽ£¨USB,serial,pc-cardµÈ£©Á¬½Óµ½PCÉϵÄbluetooth Dongle¡£
ÔÚHostÕâÒ»¶Ë£ºapplication,SDP,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 ......
#pragma once
#include <pthread.h>
class ThreadWrapper
{
public:
virtual ~ThreadWrapper();
static void EnterFunc(void *p);
int Open();
int Close();
bool TestCancel();
void ......
LinuxÊÀ½çÒ»Ö±³ÖÓÐ×ÔÓɵijç¸ßÀíÏ룬µ«ÏÖʵÉú»î×ÜÊÇÄÇô²Ð¿á£ºÃ»ÓÐÇ®ÊÇÍòÍò²»Äܵġ£
APC Magazineµ÷²é·¢ÏÖ£¬LinuxµÄ¾ø´ó¶àÊýÄں˴úÂëÊÇÓÉ´ó¹«Ë¾·¢Õ¹µÄ£¬Êý×Ö´ïµ½Á˾ªÈ˵Ä75%£¬ÕæÕýµÄÎÞ³¥Ö¾Ô¸Õß¹±Ï׵ĴúÂëÖ»Õ¼´óÔ¼²»µ½20%£¬¾ø´ó¶àÊý´úÂëÀ´×ÔÄù¤×ʵĹ«Ë¾Ô±¹¤£¬LinuxÄÚºËÿÌìÒÔ7000ÐеÄÊý¾ÝµÝÔö£¬½ö½ö´Ó2.6.28µ½2.6.32°æ±¾£¬± ......