LinuxÄÚºËͬ²½£¬½ø³Ì£¬Ïß³Ìͬ²½
°üÀ¨ÎÒ×Ô¼ºÔÚÄÚ£¬ºÜ¶àÈ˶ÔÄںˣ¬½ø³Ì£¬Ïß³Ìͬ²½¶¼²»ÊǺÜÇå³þ£¬ÏÂÃæÉÔ΢×ܽáһϣº
ÄÚºËͬ²½£º
Ö÷ÒªÊÇ·ÀÖ¹¶àºË´¦ÀíÆ÷ͬʱ·ÃÎÊÐÞ¸Äij¶Î´úÂ룬»òÕßÔÚ¶ÔÉ豸Çý¶¯³ÌÐò½øÐÐÁÙ½çÇø±£»¤¡£Ö÷ÒªÓÐһϼ¸ÖÖ·½Ê½£º
1. Mutex£¨»¥³â£©
Í·Îļþ£º
#include <linux/mutex.h>
³õʼ»¯·½·¨£º
DEFINE_MUTEX(name);»òÕß
void mutex_init(struct mutex *lock);
ʹÓ÷½·¨£º
void mutex_lock (struct mutex *lock);
Tries to lock the mutex, sleeps otherwise.
Caution: can't be interrupted, resulting in processes you cannot kill!
int mutex_lock_interruptible (struct mutex *lock);
Same, but can be interrupted. If interrupted, returns a non zero value and doesn't hold the lock. Test the return value!!!
int mutex_trylock (struct mutex *lock);
Never waits. Returns a non zero value if the mutex is not available.int mutex_is_locked(struct mutex *lock);Just tells whether the mutex is locked or not.
void mutex_unlock (struct mutex *lock);
Releases the lock. Make sure you do it as quickly as possible!
2. Reader/writer semphopres ¶ÁдÐźÅÁ¿
Allow shared access by unlimited readers, or by only 1 writer. Writers get priority.
ÔÊÐíÓÐÏÞÊýÁ¿µÄ¶Á·ÃÎÊ£¬µ«ÊÇÖ»ÄÜÓÐÒ»¸öд·ÃÎÊ¡£
void init_rwsem (struct rw_semaphore *sem);
void down_read (struct rw_semaphore *sem);
int down_read_trylock (struct rw_semaphore *sem);
int up_read (struct rw_semaphore *sem);
void down_write (struct rw_semaphore *sem);
Ïà¹ØÎĵµ£º
1. HCI²ãÐÒé¸ÅÊö£º
HCIÌṩһÌ×ͳһµÄ·½·¨À´·ÃÎÊBluetoothµ×²ã¡£ÈçͼËùʾ£º
´ÓͼÉÏ¿ÉÒÔ¿´³ö£¬Host Controller Interface(HCI) ¾ÍÊÇÓÃÀ´¹µÍ¨HostºÍModule¡£Hostͨ³£¾ÍÊÇPC£¬ ModuleÔòÊÇÒÔ¸÷ÖÖÎïÀíÁ¬½ÓÐÎʽ£¨USB,serial,pc-cardµÈ£©Á¬½Óµ½PCÉϵÄbluetooth Dongle¡£
ÔÚHostÕâÒ»¶Ë£ºapplication,SDP,L2capµÈÐÒé ......
£¨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 ......
µÚ2Õ Linux°²×°Á˽âÁËLinuxµÄÀúÊ·ºÍ·¢Õ¹¹ý³Ì£¬¶ÁÕß´ó¸ÅÒѾ¼±ÇеØÏëÒª°ÑLinux°²×°µ½×Ô¼ºµÄ¼ÆËã»úÉÏ¡£ÎÞËùη¾åµÄ¶ÁÕß¿ÉÄÜÒѾÔÚÔĶÁ±¾ÕÂ֮ǰ¾Í×ö¹ýÕâÑùµÄ³¢ÊÔ¡£ÎÞÂÛÕâЩ³¢ÊÔ×îÖÕÊdzɹ¦»¹ÊÇʧ°Ü£¬¾Í´ÓÕâÀ↑ʼLinuxÖ®Âðɣ¡ ......