Linux KernelÖÐlist½â¶Á
±êÇ©£º
it
·ÖÀࣺ
linux_kernel
×÷ÕߣºSam £¨Õç·å£© sam_code@hotmail.com
Sam֮ǰ¿´2.4
kernelʱ£¬³£¿´µ½List.Ò²×Ðϸ¿´ÁËһϣ¬µ«ÏÖÔÚ³¤ÆÚûÓп´kernel,ûÓÐд³ÌÐò£¬ÒѾÍü¼ÇÁ˺ܶࡣ½ñÌìÓÖ¿´Ò»¿´²¢¼Ç¼ÏÂÀ´¡£
Linux
KernelÖУ¬³£³£ÐèҪʹÓÃË«ÏòÁ´±í¡£ÔÚ~/include/linux/list.hÖУ¬¾Í¶¨ÒåÁËË«ÏòÁ´±íºÍ³£ÓõÄfunction.
Á´±íÍ·ÈçÏ£º
struct list_head {
struct list_head *next, *prev;
};
1.´´½¨Ë«ÏòÁ´±í£¨doubly linked
list£©£º
INIT_LIST_HEAD(
struct list_head
*list
)
´úÂëÈçÏ£º
static inline void INIT_LIST_HEAD(struct list_head *list)
{
list->next = list;
list->prev = list;
}
½«ListµÄÍ·ºÍβ¶¼Ö¸Ïò×ÔÉí¡£
2. Ìí¼ÓÄÚÈݵ½Ë«ÏòÁ´±í£º
2.1: ƽ³£µÄÌí¼Ó£º
2.1.1:½«ÐÂÏîÄ¿Ìí¼Óµ½listµÄÍ·²¿£¨headÖ®ºóµÚÒ»¸öλÖã©¡£×¢Ò⣬´Ë´¦headÊÇÖ¸´ËË«ÏòÁ´±íÍ·¡£
void list_add(struct list_head *new, struct list_head *head)
½«²ÎÊýÒ»£¨new£©Ìí¼Óµ½headÖ®ºó¡£Ëüµ÷ÓÃ
__list_add(new, head,
head->next);Ò²¾ÍÊÇ˵£¬°ÑnewÌí¼Óµ½headºÍhead->nextÖ®¼ä¡£
static inline void __list_add(struct
list_head *new,
struct list_head *prev,
struct list_head *next) //ËüÖ»Êǽ«newÌí¼Óµ½prevºÍnextÖ®¼ä
{
next->prev = new;
new->next = next;
new->prev = prev;
prev->next = new;
}
2.1.2£º½«ÐÂÏîÄ¿Ìí¼ÓË«ÏòÁ´±í×îºóÒ»¸öλÖã¨Ò²¾ÍÊÇheadµÄpriv£©¡£×¢Òâ´Ë´¦head±íʾlistÍ·¡£
static inline void list_add_tail(struct
list_head *new, struct list_head *head)
{
__list_add(new, head->prev,
head);
}
Ôò½«newÌí¼Óµ½head->prevºÍheadÖ®¼äÁË¡£
2.2:¶Á¿½±´¸üУ¨rcu£©Ä£Ê½µÄÌí¼Ó£¨smp_wmb()
£©£¨Çë¿´±³¾°ÖªÊ¶£©
2.2.1: ½«ÐÂÏîÄ¿¼Óµ½ÒÔÖªµÄprevºÍnextÖ®¼ä£º
static inline void __list_add_rcu(struct
list_head * new,
struct list_head * prev, struct
list_head * next)
{
new->next = next;
new->prev = prev;
smp_wmb();
next->prev = new;
prev->next = new;
}//´Ë´¦×¢Ò⣺smp_wmb();
smp_wmb()·ÀÖ¹±àÒëÆ÷ºÍCPUÓÅ»¯´úÂëÖ´ÐеÄ˳
Ïà¹ØÎĵµ£º
Ï̳߳أº¼òµ¥µØ˵£¬Ïß³Ì³Ø ¾ÍÊÇÔ¤ÏÈ´´½¨ºÃÒ»ÅúỊ̈߳¬·½±ã¡¢¿ìËٵش¦ÀíÊÕµ½µÄÒµÎñ¡£±ÈÆð´«Í³µÄµ½À´Ò»¸öÈÎÎñ£¬¼´Ê±´´½¨Ò»¸öÏß³ÌÀ´´¦Àí£¬½ÚÊ¡ÁËÏ̵߳Ĵ´½¨ºÍ»ØÊյĿªÏú£¬ÏìÓ¦¸ü¿ì£¬Ð§Âʸü¸ß¡£
ÔÚlinuxÖУ¬Ê¹ÓõÄÊÇposixÏ߳̿⣬Ê×ÏȽéÉܼ¸¸ö³£Óõĺ¯Êý£º
1 Ï̵߳Ĵ´½¨ºÍÈ¡Ïûº¯Êý
pthread_create
´´½¨Ïß³Ì
pthread_join
º ......
RHEL5´î½¨DNS·þÎñÆ÷ʵÏÖÃû³Æ½âÎö ËÄ
(1)ÉèÖÃÕýÏò½âÎöÇøÓò
ÕýÏò½âÎöÇøÓòÓÃÓÚʵÏÖÓòÃûµ½IPµØÖ·Ö®¼äµÄת»»¡£ÏÂÃæÊÇÒ»¸öÕýÏò½âÎöÇøÓòµÄÅäÖÃÄÚÈݾÙÀý£º
zone “my.internal.com” {
type master;
&nbs ......
“/”¸ùĿ¼
°üº¬»ù±¾µÄ²Ù×÷ϵͳºÍά»¤¹¤¾ß¡£Õâ¸öĿ¼µÄÎļþ¿ÉÒÔÆô¶¯ÏµÍ³£¬²¢ÇÒÐèÒªµÄ»°£¬¿ÉÒÔÍê³É½ô¼±Î¬»¤ºÍÐÞ¸´µÄ¹¦ÄÜ¡£
“/usr”Ŀ¼
°üº¬ËùÓеÄÃüÁî¡¢³ÌÐò¿â¡¢ÎĵµºÍÆäËüÎļþ¡£ÕâЩÎļþÔÚÕý³£²Ù×÷Öв»»á±»¸Ä±äµÄ¡£
Õâ¸öĿ¼Ҳ°üº¬ÄãµÄLinux·¢Ðа汾µÄÖ÷ÒªµÄÓ¦ÓóÌÐò£¬Æ©È磬Netscape¡£
&ldquo ......
À´×ÔÒ»±¾¾ø°æµÄÊé,ËäȻûÓк¯Êý
ÃèÊö,µ«ÊÇ×îÆðÂë¿ÉÒÔÖªµÀ·ÖÀà,¾Í¿ÉÒÔÈ¥ man ÁË
Linux Cº¯Êý¿â²Î¿¼ÊÖ²á
µÚ1ÕÂ×Ö·û²âÊÔ
º¯Êý
isalnum(²âÊÔ×Ö·ûÊÇ·ñΪӢÎÄ×Öĸ»òÊý×Ö)
isalpha(²âÊÔ×Ö·ûÊÇ·ñΪӢÎÄ×Öĸ)
isascii(²âÊÔ×Ö·ûÊÇ·ñΪASCIIÂë×Ö·û)
isblank(²âÊÔ×Ö·ûÊÇ·ñΪ¿Õ¸ñ×Ö·û)
iscntrl(²âÊÔ×Ö·ûÊÇ·ñΪASCIIÂëµÄ¿ØÖÆ×Ö·û ......