LinuxÔ×Ó²Ù×÷µÄ·ÖÎö
Linux
Ô×Ó²Ù×÷µÄ·ÖÎö
±¾ÎÄÕë¶ÔLinuxÌṩµÄÔ×Ó²Ù×÷º¯Êý
atomic_dec_and_test
×öÁËÏêϸµÄʵÀý·ÖÎö£¬½âÊÍÁËÆäÔ×ÓÐԵı¾ÖÊÒâÒå¡£
²¢¶Ô
volatile
²úÉúµÄÎó½â×öÁ˽âÊÍ¡£
1.
atomic_dec_and_test
·ÖÎö
£¨
1
£©ÏÈÀ´¿´
atomic_dec_and_test
µÄ¶¨Ò壺
11 #ifdef CONFIG_SMP
12 #define LOCK "lock ; "
13 #else
14 #define LOCK ""
15 #endif
137 static __inline__ int atomic_dec_and_test(atomic_t
_
v)
138 {
139 unsigned char c;
140
141 __asm__ __volatile__(
142 LOCK "decl %0; sete %1"
143 :"=m" (v->counter), "=qm" (c)
144 :"m" (v->counter) : "memory");
145 return c !
=
0;
146 }
11–15 this macro is used in the inline assembly part of
some of the functions that follow. It means that
the LOCK macro can always be used. But sometimes (the SMP
case) it invokes the machine
instruction to lock the bus; other times it has no
effect.
142 the SETE instruction sets parameter 1 (the unsigned
char c) to 1 if the zero bit is set in
EFLAGS (i.e. if the result of the subtraction was 0).
143 parameter 0 (the counter field) is write only ("=")
and may be in memory ("m"). Parameter 1
is the unsigned char c declared on line 139. It may be in
a general purpose register, or in
memory ("=qm").
144 parameter 2 is the input parameter i; it is expected
as an immediate integer operand and may be
in a general register ("ir") . Parameter 3 is
the other input, the value in (v-
.
counter)
beforehand. The "memory" operand constraint
tells the compiler that memory will be modified
in an unpredictable manner, so it will not keep memory
values cached in registers across the
group of assembler instructions.
145 if the result of the decrement was 0, then c was set
to 1 on line 142. In that case, c !
=
0 is TRUE.
Otherwise, c was set to 0, and c !
=
0 is FALS
Ïà¹ØÎĵµ£º
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¡¢ ÈçºÎÔÚLinuxϵͳÏÂÌí¼ÓÒ»¸öÕÊ»§£ºÓû§ÃûΪstd02£¬ÃÜÂëΪpwd02?
£º#useradd std02
#passwd std02
³öÏÖÌáʾÊäÈë¿ÚÁîpwd02£¬Ôٴΰ´ÌáʾÊäÈëpwd02
Ò²¿ÉÒÔ:
#useradd -n std02 -p pwd02
2¡¢ н¨Ò»¸ö×ÓĿ¼/home/public£¬ÈÃËü±»ËùÓеÄÓû§¹²Ïí£¬¶øÇÒÓµÓÐËùÓÐȨÏÞ£¬µ«²»Äܱ»·ÇÊôÖ÷ɾ³ý£¿
£º#mkdir /home/public
#chm ......
£¨Ò»£© ÍøÂçÖб鲼×Å´óÁ¿µÄLinuxÏà¹ØÕ¾µã£»
£¨¶þ£© Óû§ÎÞÐëÏêϸÁ˽âÿһ¸ö´ËÀàÕ¾µã£¬Êµ¼ÊÉÏ£¬Ò»°Ù¸öÕ¾µã×ã¹»ÄãʹÓÃÁË¡£
ÆÀÑ¡³öµÄÕâ100¸öÓÅÐãÕ¾µã£¬½«°´ÕÕÏÂÊö20¸öÀà±ð×÷ÒÔÆÀ½é£º
£¨Ò»£© ÎļþÏÂÔØ
£¨¶þ£© ÓÄĬÓéÀÖ
£¨Èý£© Ïà¹ØÐÂÎÅ
£¨ËÄ£© ͨÓÃÓ²¼þ
£¨Î壩 רÓÃÓ²¼þ
£¨Áù£© ÐÂÊÖÕ¾µã
£¨Æߣ© ͼÐÎ/¶àÃ½Ì ......
make µÄÔËÐÐ
——————
Ò»°ãÀ´Ëµ£¬×î¼òµ¥µÄ¾ÍÊÇÖ±½ÓÔÚÃüÁîÐÐÏÂÊäÈëmakeÃüÁmakeÃüÁî»áÕÒµ±Ç°Ä¿Â¼µÄmakefileÀ´Ö´ÐУ¬Ò»Çж¼ÊÇ×Ô¶¯µÄ¡£µ«Ò²ÓÐʱÄãÒ²ÐíÖ»ÏëÈÃmakeÖرàÒëijЩÎļþ£¬¶ø²»ÊÇÕû¸ö¹¤³Ì£¬¶øÓÖÓеÄʱºòÄãÓм¸Ì×±àÒë¹æÔò£¬ÄãÏëÔÚ²»Í¬µÄʱºòʹÓò»Í¬µÄ±àÒë¹æÔò£¬µÈµÈ¡£±¾Õ½ھÍÊ ......
½ñÌìÍê³ÉÁËǶÈëʽlinuxµÄµÚÒ»¸öÇý¶¯µÄ±àдºÍ²âÊÔ£¬ËäÈ»ÊǸö¼òµ¥µÄ³ÌÐò£¬µ«ÊÇÂéȸËäС£¬ÎåÔà¾ãÈ«£¬Ï£Íû¿ÉÒÔ¸ø¸Õ¿ªÊ¼½Ó´¥Çý¶¯±àдµÄÈËһЩÌáʾ£¬¹²Í¬½ø²½¡£
Ô´´úÂ룺
·ÖÎöÈçÏ£º
ÏÂÃæÊÇÎÒµÄÇý¶¯³ÌÐò£º
#include <linux/config.h>//ÅäÖÃÍ·Îļþ
#include <linux/kernel.h&g ......