Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

ÔÚlinuxÖеÄlikelyºÍunlikely

ÔÚlinuxÖеÄlikelyºÍunlikely
0
ÍÆ¼ö
ÔÚlinuxÖÐÅжÏÓï¾ä¾­³£»á¿´µ½likelyºÍunlikely£¬ÀýÈ磺
if(likely(value)){
}
else{
}
¼òµ¥´Ó±íÃæÉÏ¿´if(likely(value)) == if(value)£¬if(unlikely(value)) == if(value)¡£
ÕâÁ½¸öºê¶Ô³ÌÐòÔËÐнá¹ûûÓÐÓ°Ï죬ֻÊÇÓÃÓÚÌá¸ß³ÌÐòЧÂÊ¡£ÆäʵÏÖºÍgcc±àÒëÆ÷ÃÜÇÐÏà¹Ø¡£
¾ßÌåµã˵£¬¾ÍÊÇÈç¹ûÄã¾õµÃ³ÌÐòÔËÐÐʱºòÒ»°ãsndcmd|=0µÄ¿ÉÄÜÐԱȽϴó£¬ÄÇô¾Í¼ÓÉÏlikelyµÄmacro£»·´Ö®Ôò¼Óunlikely¡£
Ò²¾ÍÊÇlikelyºÍunlikelyÊÇÒ»ÑùµÄ£¬µ«ÊÇʵ¼ÊÉÏÖ´ÐÐÊDz»Í¬µÄ£¬¼ÓlikelyµÄÒâʶÊÇvalueµÄÖµÎªÕæµÄ¿ÉÄÜ
ÐÔ¸ü´óһЩ£¬ÄÇôִÐÐifµÄ»ú»á´ó£¬¶øunlikely±íʾvalueµÄֵΪ¼ÙµÄ¿ÉÄÜÐÔ´óһЩ£¬Ö´ÐÐelse»ú»á´óһЩ¡£
¼ÓÉÏÕâÖÖÐÞÊΣ¬±àÒë³É¶þ½øÖÆ´úÂëʱlikelyʹµÃifºóÃæµÄÖ´ÐÐÓï¾ä½ô¸ú×ÅÇ°ÃæµÄ³ÌÐò£¬unlikelyʹµÃelseºó
ÃæµÄÓï¾ä½ô¸ú×ÅÇ°ÃæµÄ³ÌÐò£¬ÕâÑù¾Í»á±»cacheÔ¤¶ÁÈ¡£¬Ôö¼Ó³ÌÐòµÄÖ´ÐÐËÙ¶È£¬likelyºÍunlikelyµÄʵÏÖÔÚ
include/linux/compiler.hÖУº
      9 #if __GNUC__ == 2 && __GNUC_MINOR__ < 96
     10 #define __builtin_expect(x, expected_value) (x)
     11 #endif
     12
     13 #define likely(x)   __builtin_expect((x),1)
     14 #define unlikely(x) __builtin_expect((x),0)
__builtin_expectÊÇgccµÄÒ»¸öÔ¤´¦ÀíÃüÁÆä½âÊÍÈçÏ£º
long __builtin_expect (long exp, long c)
You may use __builtin_expect to provide the compiler with branch prediction
information. In general, you should prefer to use actual profile feedback for this
(‘-fprofile-arcs’), as programmers are notoriously bad at predicting how their
programs actually perform. However, there are applications in which this data is
hard to collect.
The return value is the value of exp, which should be an integral expression. The
value of c must be a compile-time constant. The semantics of the built-in are that it
is expected that exp == c. For example:
if (__builtin_expect (x, 0))
foo ();
would indicate that we do not expect to call foo, since we expect x to be zero. Since
you are limited to i


Ïà¹ØÎĵµ£º

Linux µÄ¶àÏ̱߳à³ÌµÄ¸ßЧ¿ª·¢¾­Ñé

2009 Äê 4 ÔÂ 23 ÈÕ
±¾ÎÄÖÐÎÒÃÇÕë¶Ô Linux É϶àÏ̱߳à³ÌµÄÖ÷ÒªÌØÐÔ×ܽá³ö 5 Ìõ¾­Ñ飬ÓÃÒÔ¸ÄÉÆ Linux ¶àÏ̱߳à³ÌµÄϰ¹ßºÍ±ÜÃâÆäÖеĿª·¢ÏÝÚå¡£ÔÚ±¾ÎÄÖУ¬ÎÒÃÇ´©²åһЩ Windows µÄ±à³ÌÓÃÀýÓÃÒÔ¶Ô±È Linux ÌØÐÔ£¬ÒÔ¼ÓÉî¶ÁÕßÓ¡Ïó¡£
±³¾°
Linux ƽ̨ÉϵĶàÏ̳߳ÌÐò¿ª·¢Ïà¶ÔÓ¦ÆäËûƽ̨£¨±ÈÈç Windows£©µÄ¶àÏß³Ì API ÓÐһЩϸ΢ ......

ARM LinuxÆô¶¯¹ý³Ì·ÖÎö


Õª Òª£º ǶÈëʽ Linux µÄ¿ÉÒÆÖ²ÐÔʹµÃÎÒÃÇ¿ÉÒÔÔÚ¸÷ÖÖµç×Ó²úÆ·ÉÏ¿´µ½ËüµÄÉíÓ°¡£¶ÔÓÚ²»
ͬÌåϵ½á¹¹µÄ´¦ÀíÆ÷À´ËµLinuxµÄÆô¶¯¹ý³ÌÒ²ÓÐËù²»Í¬¡£±¾ÎÄÒÔS3C2410 ARM´¦ÀíÆ÷ΪÀý£¬
Ïêϸ·ÖÎöÁËϵͳÉϵçºó bootloaderµÄÖ´ÐÐÁ÷³Ì¼° ARM LinuxµÄÆô¶¯¹ý³Ì¡£
......

Linux϶ÁÓ²ÅÌÐòÁкŵijÌÐò


Linux϶ÁÓ²ÅÌÐòÁкŵijÌÐò
/*
* gethddsn.c
*
* Get serial number of ide hard disk.
* example: my Maxtor 15G 's s/n is K306S04C.
*
* Compile with: gcc -O2 gethddsn.c
*
* Xiaoming DONG <xmdong@263.net>
* Aug 24, 2000
*
*/
#include <stdio.h>
#include <stdlib.h>
#includ ......

linux·½ÃæµÄÔÓ̸

1.ÔÚshell½Å±¾ÖлáÓõ½ifÅжϣ¬ÊÂʵÉϾÍÊÇtest¼Ó²ÎÊýÖ´ÐеĽá¹û£¬±ÈÈ磺
if test -f /xxx ;then YYY ;fi£¬µ«ÊÇ»¹ÓÐÁíÒ»ÖÖд·¨£¬ÄǾÍÊÇif [ abc ];then YYY£¬Êµ¼ÊÉÏ“[”Ò²ÊÇÒ»¸öÃüÁÓÃwhereis [¿ÉÒÔ֤ʵ£¬¸Ã“[”³ÌÐòÖбØÈ»ÒªÓÐÒ»¸ö“]”×÷Ϊ²ÎÊý£¬È»ºóÅжÏ$1µ½"]"Ö®¼äµÄ²ÎÊýµÄ ......

ѧϰ±Ê¼Ç Unix/Linux½ø³Ì¼äͨÐÅ

ÃæÊÔʱһÔٵر»Îʵ½½ø³Ì¼äͨÐŵÄÇé¿ö£¬¶øÎÒµÄÀí½âһֱͣÁôÔÚ¸ÅÄîÉϺÍÃû´ÊÉÏ£¬±ØÐëÒª×öµãʵÑé¼ÓÉîÀí½â¡£
IPC:Interprocess communication¡£ÓÐЩIPCµÄ·½·¨²»½ö¿ÉÒÔÓÃÓÚÏàͬÖ÷»ú£¬Ò²¿ÉÒÔÓÃÓÚ²»Í¬Ö÷»ú£¬ÈçsocketsºÍSTREAMS¡£
¾­µäIPCÖ®Ò»£ºpipes(¹ÜµÀ)
,ʹÓÃ×î¹ã·º£¬¾ßÓÐÇ×Ôµ¹ØÏµ
µÄ½ø³Ì¼ä²ÅÄÜʹÓùܵÀ½øÐÐIPC¡£
ʹÓÃÁ˹ܵ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ