LinuxϵĶδíÎó²úÉúµÄÔÒò¼°µ÷ÊÔ·½·¨
LinuxϵĶδíÎó²úÉúµÄÔÒò¼°µ÷ÊÔ·½·¨
ĬÈÏ·ÖÀà 2008-08-26 13:37 ÔĶÁ28 ÆÀÂÛ0
×ֺţº ´ó´ó ÖÐÖРСС
¼ò¶øÑÔÖ®,²úÉú¶Î´íÎó¾ÍÊÇ·ÃÎÊÁË´íÎóµÄÄÚ´æ¶Î£¬Ò»°ãÊÇÄãûÓÐȨÏÞ£¬»òÕ߸ù±¾¾Í²»´æÔÚ¶ÔÓ¦µÄÎïÀíÄÚ´æ,ÓÈÆä³£¼ûµÄÊÇ·ÃÎÊ0µØÖ·.
Ò»°ãÀ´Ëµ,¶Î´íÎó¾ÍÊÇÖ¸·ÃÎʵÄÄڴ泬³öÁËϵͳËù¸øÕâ¸ö³ÌÐòµÄÄÚ´æ¿Õ¼ä£¬Í¨³£Õâ¸öÖµÊÇÓÉgdtrÀ´±£´æµÄ£¬ËûÊÇÒ»¸ö48λµÄ¼Ä´æÆ÷£¬ÆäÖеÄ32λÊDZ£´æÓÉËüÖ¸ÏòµÄgdt±í£¬ºó13λ±£´æÏàÓ¦ÓÚgdtµÄϱ꣬×îºó3λ°üÀ¨Á˳ÌÐòÊÇ·ñÔÚÄÚ´æÖÐÒÔ¼°³ÌÐòµÄÔÚcpuÖеÄÔËÐ춱ð,Ö¸ÏòµÄgdtÊÇÓÉÒÔ64λΪһ¸öµ¥Î»µÄ±í£¬ÔÚÕâÕűíÖоͱ£´æ×ųÌÐòÔËÐеĴúÂë¶ÎÒÔ¼°Êý¾Ý¶ÎµÄÆðʼµØÖ·ÒÔ¼°Óë´ËÏàÓ¦µÄ¶ÎÏÞºÍÒ³Ãæ½»»»»¹ÓгÌÐòÔËÐ춱ð»¹ÓÐÄÚ´æÁ£¶ÈµÈµÈµÄÐÅÏ¢¡£Ò»µ©Ò»¸ö³ÌÐò·¢ÉúÁËÔ½½ç·ÃÎÊ£¬cpu¾Í»á²úÉúÏàÓ¦µÄÒì³£±£»¤£¬ÓÚÊÇsegmentation fault¾Í³öÏÖÁË.
ÔÚ±à³ÌÖÐÒÔϼ¸Àà×ö·¨ÈÝÒ×µ¼Ö¶δíÎó,»ù±¾ÊÇÊÇ´íÎóµØʹÓÃÖ¸ÕëÒýÆðµÄ
1)·ÃÎÊϵͳÊý¾ÝÇø£¬ÓÈÆäÊÇÍù ϵͳ±£»¤µÄÄÚ´æµØַдÊý¾Ý
×î³£¼û¾ÍÊǸøÒ»¸öÖ¸ÕëÒÔ0µØÖ·
2)ÄÚ´æÔ½½ç(Êý×éÔ½½ç£¬±äÁ¿ÀàÐͲ»Ò»ÖµÈ) ·ÃÎʵ½²»ÊôÓÚÄãµÄÄÚ´æÇøÓò
½â¾ö·½·¨
ÎÒÃÇÔÚÓÃC/C++ÓïÑÔд³ÌÐòµÄʱºî£¬ÄÚ´æ¹ÜÀíµÄ¾ø´ó²¿·Ö¹¤×÷¶¼ÊÇÐèÒªÎÒÃÇÀ´×öµÄ¡£Êµ¼ÊÉÏ£¬ÄÚ´æ¹ÜÀíÊÇÒ»¸ö±È½Ï·±ËöµÄ¹¤×÷£¬ÎÞÂÛÄã¶à¸ßÃ÷£¬¾Ñé¶à·á¸»£¬ÄÑ Ãâ»áÔÚ´Ë´¦·¸Ð©Ð¡´íÎ󣬶øͨ³£ÕâЩ´íÎóÓÖÊÇÄÇôµÄdzÏÔ¶øÒ×ÓÚÏû³ý¡£µ«ÊÇÊÖ¹¤“³ý³æ”£¨debug£©£¬ÍùÍùÊÇЧÂʵÍÏÂÇÒÈÃÈËÑá·³µÄ£¬±¾ÎĽ«¾Í"¶Î´íÎó"Õâ¸ö ÄÚ´æ·ÃÎÊÔ½½çµÄ´íÎó̸̸ÈçºÎ¿ìËÙ¶¨Î»ÕâЩ"¶Î´íÎó"µÄÓï¾ä¡£
ÏÂÃ潫¾ÍÒÔϵÄÒ»¸ö´æÔڶδíÎóµÄ³ÌÐò½éÉܼ¸ÖÖµ÷ÊÔ·½·¨£º
1 dummy_function (void)
2 {
3 unsigned char *ptr = 0x00;
4 *ptr = 0x00;
5 }
6
7 int main (void)
8 {
9 dummy_function ();
10
11 &nb
Ïà¹ØÎĵµ£º
1. HCI²ãÐÒé¸ÅÊö£º
HCIÌṩһÌ×ͳһµÄ·½·¨À´·ÃÎÊBluetoothµ×²ã¡£ÈçͼËùʾ£º
´ÓͼÉÏ¿ÉÒÔ¿´³ö£¬Host Controller Interface(HCI) ¾ÍÊÇÓÃÀ´¹µÍ¨HostºÍModule¡£Hostͨ³£¾ÍÊÇPC£¬ ModuleÔòÊÇÒÔ¸÷ÖÖÎïÀíÁ¬½ÓÐÎʽ£¨USB,serial,pc-cardµÈ£©Á¬½Óµ½PCÉϵÄbluetooth Dongle¡£
ÔÚHostÕâÒ»¶Ë£ºapplication,SDP,L2capµÈÐÒé ......
1. ѧ»áд¼òµ¥µÄmakefile
2. ±àһЩӦÓÃ
³ÌÐò
£¬¿ÉÒÔÓÃmakefileÅÜÆðÀ´
3. ѧ»áдÇý¶¯
µÄmakefile
4. дһ¼òµ¥charÇý¶¯£¬makefile±àÒëͨ¹ý£¬¿ÉÒÔinsmod£¬ lsmod£¬ rmmod. ÔÚÇý¶¯µÄinitº¯ÊýÀï´òÓ¡hello world£¬insmodºóÓ¦¸ÃÄܹ»Í¨¹ýdmesg¿´µ½Êä³ö
¡£
5. дһÍêÕûÇý¶¯£¬ ¼ÓÉÏread£¬ write£¬ ioctl£¬ pollingµÈ¸ ......
ϵͳµ÷ÓÃÊÇÓ¦ÓóÌÐòºÍ²Ù×÷ϵͳÄÚºËÖ®¼äµÄ¹¦Äܽӿڡ£ÆäÖ÷ҪĿµÄÊÇʹµÃÓû§
¿ÉÒÔʹÓòÙ×÷ϵͳÌṩµÄÓйØÉ豸¹ÜÀí¡¢ÊäÈë/ÊäÈëϵͳ¡¢ÎļþϵͳºÍ½ø³Ì¿ØÖÆ¡¢
ͨÐÅÒÔ¼°´æ´¢¹ÜÀíµÈ·½ÃæµÄ¹¦ÄÜ£¬¶ø²»±ØÁ˽âϵͳ³ÌÐòµÄÄÚ²¿½á¹¹ºÍÓйØÓ²¼þϸ
½Ú£¬´Ó¶øÆðµ½¼õÇáÓû§¸ºµ£ºÍ±£»¤ÏµÍ³ÒÔ¼°Ìá¸ß×ÊÔ´ÀûÓÃÂʵÄ×÷Óá£
¡¡¡¡Linux²Ù×÷ϵͳ ......
Purpose
This examples shows how to create and stop a kernel thread.
The driver is implemented as a loadable module. In the init_module() routine five kernel threads are created. This kernel threads sleep one second, wake up, print a message and fall asleep again. On unload of the module (cle ......