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

LinuxÖÐALIGNºêµÄÔ­Àí

1. Òý×Ó
int a;  
int size = 8;
   
Èç¹ûÈÃaΪ(size =8)µÄÕûÊý±¶±íʾ³É¶þ½øÖÆÓ¦ÊÇʲôÑù×ÓÄØ£¿ÄǾÍÊÇÈÃÕâ¸öÊý±íʾ³É¶þ½øÖÆʱµÄ×îºóÈýλΪ0.
¶øÒª´ïµ½ÕâһĿ±ê£¬Ö»ÒªÏÂÃæÕâ¸öÊýÓëËü½øÐÐÓëÔËËã¾Í¿ÉÒÔÁË:
  11111111 11111111 11111111 11111000  
¶øÉÏÃæÕâ¸öÊýʵ¼ÊϾÍÊÇ ~ (size - 1)£¬¿ÉÒÔ½«¸ÃÊý³ÆΪsizeµÄ¶ÔÆëÑÚÂësize_mask.  
   
¿ÉÕâÑù×öÇó³öµÄÊDZÈaСµÄÄǸö×î´óµÄ8µÄ±¶Êý. Èç¹ûÒªÇó³ö±Èa´óµÄÊDz»ÊÇÐèÒª¼ÓÉÏ8¾Í¿ÉÒÔÁË?
¿ÉÊÇÈç¹ûa±¾Éí¾ÍÊÇ8µÄ±¶Êý, ÕâÑù¼Ó8²»¾Í´íÁËÂð, ËùÒÔÔÚa»ù´¡ÉϼÓÉÏ size - 1, È»ºóÓësizeµÄ¶ÔÆëÑÚÂë½øÐÐÓëÔËËã.
ÕâÑù, ÎÒÃÇ¿ÉÒÔ¶¨ÒåÏÂÃæµÄºê, ÓÃÓÚ¼ÆËãÒ»¸öÊýaÒÔsizeΪ±¶ÊýµÄÇ°ºóÁ½¸öÖµ£º
#define alignment_down(a, size) (a & (~(size-1)) )
#define alignment_up(a, size) ((a+size-1) & (~ (size-1)))
 
ÀýÈç:
a=0, size=8,  Ôòalignment_down(a,size)=0, alignment_up(a,size)=0.
a=6, size=8,  Ôòalignment_down(a,size)=0, alignment_up(a,size)=8.
a=8, size=8,  Ôòalignment_down(a,size)=8, alignment_up(a,size)=8.
a=14, size=8, Ôòalignment_down(a,size)=8, alignment_up(a,size)=16.
 
×¢Ò⣺sizeÓ¦µ±Îª2µÄn´Î·½, ¼´2, 4, 8, 16, 32, 64, 128, 256, 1024, 2048, 4096.....
 
2. ÔÚlinuxÖеÄÓ¦ÓÃ
ÉÏÃæµÄ¼ÆËã·½·¨ÔÚlinuxµÈ´úÂëÖÐÒ²³£³£¿ÉÒÔ¿´µ½,ÏÂÃæ¸ø³ö¼¸¸öÀý×Ó.
 
Àý£±£ºµ±·ÖÅäµØÖ·addrʱ, Òª½«¸ÃµØÖ·ÒÔsizeΪ±¶Êý¶ÔÆë, ¶øÇÒÒªµÃµ½ÊDZÈaddr´óµÄÖµ, ÔòʹÓÃ_ALIGNºê£º
/* align addr on a size boundary - adjust address up if needed -- Cort */
#define _ALIGN(addr,size)   (((addr)+(size)-1)&(~((size)-1)))
Àý2£ºÓëÒ³Ãæ¶ÔÆëÏà¹ØµÄºê
#define PAGE_SIZE               4096
#define PAGE_MASK               (~(PAGE_SIZE-1))
/* to align the pointer to the (next) page boundary */
#define PAGE_ALIGN(addr)        (((addr)+PAGE_SIZE-1) & PAGE_MASK)
 
Àý3£ºÓëskb·ÖÅäʱ¶ÔÆëÏà¹ØµÄºê
#define SKB_DATA_ALIGN(X)  


Ïà¹ØÎĵµ£º

linux ar ÃüÁîÏê½â


¹¦ÄÜ˵Ã÷£º½¨Á¢»òÐ޸ı¸´æÎļþ£¬»òÊÇ´Ó±¸´æÎļþÖгéÈ¡Îļþ¡£
Óï¡¡¡¡·¨£ºar[-dmpqrtx][cfosSuvV][a<³ÉÔ±Îļþ>][b<³ÉÔ±Îļþ>][i<³ÉÔ±Îļþ>][±¸´æÎļþ][³ÉÔ±Îļþ]
²¹³ä˵Ã÷£ºar¿ÉÈÃÄú¼¯ºÏÐí¶àÎļþ£¬³ÉΪµ¥Ò»µÄ±¸´æÎļþ¡£ÔÚ±¸´æÎļþÖУ¬ËùÓгÉÔ±Îļþ½Ô±£ÓÐÔ­À´µÄÊôÐÔÓëȨÏÞ¡£
²Î¡¡¡¡Êý£º
¡¡Ö¸Áî²ÎÊý
¡ ......

Linux netfilterÔ´Âë·ÖÎö(4)


ËÄ¡¢nf_hook_ops ¹³×ÓµÄ×¢²á
ÔÚfilter±íµÄ³õʼ»¯º¯Êýstatic int __init init(void)ÖгýÁËÓÐÒ»¸önf_register_hookº¯Êý×¢²áÒ»¸ötablesÍ⣬»¹ÓÉnf_register_hookº¯Êý×¢²áÁË3¸öhook
 
4.1        nf_hook_opsÊý¾Ý½á¹¹ netfilter.h
struct nf_hook_ops
{
      ......

Éî¿ÌÀí½âLinux½ø³Ì¼äͨÐÅ£¨IPC£©


Éî¿ÌÀí½âLinux½ø³Ì¼äͨÐÅ£¨IPC£©
ÎĵµÑ¡Ïî
<tr
valign="top"><td width="8"><img alt="" height="1" width="8"
src="//www.ibm.com/i/c.gif"/></td><td width="16"><img alt="" width="16&q ......

LinuxÏÂOracle9i RMAN±¸·Ý¼°»Ö¸´²½Öè½éÉÜ

1¡¢×ª»»·þÎñÆ÷¹éµµÄ£Ê½£¬Èç¹ûÒÑÊǹ鵵ģʽ¿ÉÌø¹ý´Ë²½£º
  ¡¡%sqlplus /nolog (Æô¶¯sqlplus)
¡¡¡¡SQL> conn / as sysdba (ÒÔDBAÉí·ÝÁ¬½ÓÊý¾Ý¿â)
¡¡¡¡SQL> shutdown immediate; (¼´Ê±¹Ø±ÕÊý¾Ý¿â)
¡¡¡¡SQL> startup mount (Æô¶¯ÊµÀý²¢¼ÓÔØÊý¾Ý¿â£¬µ«²»´ò¿ª)
¡¡¡¡SQL> alter database archivelog; (¸ü¸ÄÊ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ