Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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ÄÚºËÅäÖÃÎĵµ(make menuconfig)

Ò»¡¢ÒýÑÔ£º
    ±¾ÎĵµµÄÄÚÈݴ󲿷ÝÄÚÈݶ¼ÊÇ´ÓÍøÉÏÊÕ¼¯¶øÀ´£¬È»ºóÅäºÏһЩеĽØͼ£¨Äں˰汾£ºV2.4.19£©¡£ÔÚÿһÅäÖÃÏîºó»áÓÐÒ»¸öÑ¡ÔñÖ¸ÄϵIJ¿·Ý£¬ÓÃÀ´Ö¸µ¼´ó¼ÒÔõôÑù¸ù¾Ý×Ô¼ºµÄÇé¿öÀ´×öÏàÓ¦µÄÑ¡Ôñ£»»¹ÓÐÔÚÿһ¸ö´óÏîºÍÎĵµµÄ×îºó»áÓÐÒ»¸ö¾­Ñé̸£¬ËüÊÇһЩ¸ßÊÖÃÇÔÚÓ¦¶ÔÎÊÌâºÍ´¦ÀíÌØÓÐÓ²¼þʱµÄһЩ¾­Ñ飨Õâ¸ö»¹µ ......

linuxÄÚºËregister_chrdev_region()ϵÁк¯Êý

ÄÚºËÖÐËùÓÐÒÑ·ÖÅäµÄ×Ö·ûÉ豸±àºÅ¶¼¼Ç¼ÔÚÒ»¸öÃûΪ chrdevs É¢ÁбíÀï¡£¸ÃÉ¢ÁбíÖеÄÿһ¸öÔªËØÊÇÒ»¸ö char_device_struct ½á¹¹£¬ËüµÄ¶¨ÒåÈçÏ£º
   static struct char_device_struct {
       struct char_device_struct *next;    // Ö¸ÏòÉ¢ÁгåÍ»Á´±íÖеÄÏÂÒ»¸öÔªËØ ......

LinuxÄÚºË: ÐÞ¸ÄTCP/IPµ÷ÓŲÎÊý

ÔÚTimesTenµÄÓÅ»¯ÖУ¬Èç¹ûÉæ¼°µ½ Replication »òÕßCache GroupµÄ»°£¬ÄÇôÕë¶Ô TCP/IPÏà¹ØµÄ²ÎÊýµÄÓÅ»¯¶ÔÐÔÄÜÊÇÓÐÒæµÄ¡£ÒòΪËüÃÇÁ©¶¼ÊÇͨ¹ýTCP/IPЭÒé½øÐÐÊý¾Ý½»»¥µÄ¡£ÔÚ°²×°Îĵµ(install.pdf)µÄ39Ò³ÓоßÌåµÄ˵Ã÷£º
 
For replication, TCP send and receive buffers should be increased to a minimum of 512KB. To ......

Linux³£ÓÃÃüÁî

Linux³£ÓÃÃüÁîÇåµ¥
 
NO
·ÖÀà
PS1
ÃüÁîÃû
Ó÷¨¼°²ÎÊý
¹¦ÄÜ×¢½â
 
1
Îļþ¹ÜÀí
#
ls
ls -a
Áгöµ±Ç°Ä¿Â¼ÏµÄËùÓÐÎļþ£¬°üÀ¨ÒÔ.Í·µÄÒþº¬Îļþ
 
 
Îļþ¹ÜÀí
#
ls
ls -l»òll
Áгöµ±Ç°Ä¿Â¼ÏÂÎļþµÄÏêϸÐÅÏ¢
 
 
Îļþ¹ÜÀí
#
pwd
pwd
²é¿´µ±Ç°ËùÔÚĿ¼µÄ¾ø¶Ô·¾­
  ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ