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

Linux»ùÓÚʼþÇý¶¯µÄ³ÌÐò¿ò¼Ü(תÔØ)

[ת]Linux 2.6 ÄÚºËEpollÓ÷¨¾ÙÀý˵Ã÷
epollÓõ½µÄËùÓк¯Êý¶¼ÊÇÔÚÍ·Îļþsys/epoll.hÖÐÉùÃ÷µÄ£¬ÏÂÃæ¼òҪ˵Ã÷ËùÓõ½µÄÊý¾Ý½á¹¹ºÍº¯Êý£º
ËùÓõ½µÄÊý¾Ý½á¹¹:
 
typedef union epoll_data {
void *ptr;
int fd;
__uint32_t u32;
__uint64_t u64;
} epoll_data_t;
struct epoll_event {
__uint32_t events; /* Epoll events */
epoll_data_t data; /* User data variable */
};
½á¹¹Ìåepoll_event ±»ÓÃÓÚ×¢²áËù¸ÐÐËȤµÄʼþºÍ»Ø´«Ëù·¢Éú´ý´¦ÀíµÄʼþ£¬ÆäÖÐepoll_data ÁªºÏÌåÓÃÀ´±£´æ´¥·¢Ê¼þµÄij¸öÎļþÃèÊö·ûÏà¹ØµÄÊý¾Ý£¬ÀýÈçÒ»¸öclientÁ¬½Óµ½·þÎñÆ÷£¬·þÎñÆ÷ͨ¹ýµ÷ÓÃacceptº¯Êý¿ÉÒԵõ½ÓÚÕâ¸öclient¶ÔÓ¦µÄsocketÎļþÃèÊö·û£¬¿ÉÒÔ°ÑÕâÎļþÃèÊö·û¸³¸øepoll_dataµÄfd×Ö¶ÎÒÔ±ãºóÃæµÄ¶Áд²Ù×÷ÔÚÕâ¸öÎļþÃèÊö·ûÉϽøÐС£epoll_event ½á¹¹ÌåµÄevents×Ö¶ÎÊDZíʾ¸ÐÐËȤµÄʼþºÍ±»´¥·¢µÄʼþ£¬³£ÓõÄȡֵΪ£º
EPOLLIN £º±íʾ¶ÔÓ¦µÄÎļþÃèÊö·û¿ÉÒÔ¶Á£»
EPOLLOUT£º±íʾ¶ÔÓ¦µÄÎļþÃèÊö·û¿ÉÒÔд£»
EPOLLPRI£º±íʾ¶ÔÓ¦µÄÎļþÃèÊö·ûÓнô¼±µÄÊý¾Ý¿É¶Á£»
EPOLLERR£º±íʾ¶ÔÓ¦µÄÎļþÃèÊö·û·¢Éú´íÎó£»
EPOLLHUP£º±íʾ¶ÔÓ¦µÄÎļþÃèÊö·û±»¹Ò¶Ï£»
EPOLLET£ºÉèÖÃΪ Edge Triggered ģʽ¡£
ËùÓõ½µÄº¯Êý£º
1¡¢epoll_createº¯Êý
º¯ÊýÉùÃ÷£ºint epoll_create(int size)
¸Ãº¯ÊýÉú³ÉÒ»¸öepollרÓõÄÎļþÃèÊö·û£¬ÆäÖÐ size ÌáʾÄÚºËÓ¦¸Ã·ÖÅä×ãÒÔÖ§³Ö size ¸öÃèÊö·ûµÄ¿Õ¼ä¡£
2¡¢epoll_ctlº¯Êý
º¯ÊýÉùÃ÷£ºint epoll_ctl(int epfd, int op, int fd, struct epoll_event *event)
¸Ãº¯ÊýÓÃÓÚ¿ØÖÆij¸öÎļþÃèÊö·ûÉϵÄʼþ£¬¿ÉÒÔ×¢²áʼþ£¬ÐÞ¸Äʼþ£¬É¾³ýʼþ¡£
²ÎÊý£ºepfd£ºÓÉ epoll_create Éú³ÉµÄepollרÓõÄÎļþÃèÊö·û£»
op£ºÒª½øÐеIJÙ×÷ÀýÈç×¢²áʼþ£¬¿ÉÄܵÄÈ¡ÖµEPOLL_CTL_ADD ×¢²á¡¢EPOLL_CTL_MOD Ð޸ġ¢EPOLL_CTL_DEL ɾ³ý
fd£º¹ØÁªµÄÎļþÃèÊö·û£»
event£ºÖ¸Ïòepoll_eventµÄÖ¸Õ룻
Èç¹ûµ÷Óóɹ¦·µ»Ø0,²»³É¹¦·µ»Ø-1
3¡¢epoll_waitº¯Êý
º¯ÊýÉùÃ÷:int epoll_wait(int epfd,struct epoll_event * events,int maxevents,int timeout)
¸Ãº¯ÊýÓÃÓÚÂÖѯI/OʼþµÄ·¢Éú£»
²ÎÊý£º
epfd:ÓÉepoll_create Éú³ÉµÄepollרÓõÄÎļþÃèÊö·û£»
epoll_event:ÓÃÓڻش«´ý´¦ÀíʼþµÄÊý×飻
maxevents:ÿ´ÎÄÜ´¦ÀíµÄʼþÊý£»
timeou


Ïà¹ØÎĵµ£º

Linux Çý¶¯ hello

#include <linux/module.h>
MODULE_LICENSE("GPL");
static void hello_init(void);
static void hello_exit(void);
static void hello_init(void)
{
     printk("init");
}
static void hello_exit(void)
{
    printk("exit");
}
.
module_init(hello_init);
m ......

LinuxϵÄIPv6µØÖ·¡¢Â·ÓÉÒÔ¼°ËíµÀÅäÖÃ

    Èç½ñ£¬¼¸ºõËùÓеÄÖ÷Á÷²Ù×÷ϵͳ¡¢Ç¶Èëʽ²Ù×÷Ìṩϵͳ¶¼ÌṩÁ˶ÔIPv6ЭÒéÕ»µÄÖ§³Ö£¬ÔÚwindows XPÏÂÃ棬ʹÓÃipv6 installÃüÁî±ã¿ÉÒÔÆô¶¯IPv6ЭÒéÕ»£¬ÔÚĬÈÏ°²×°µÄlinuxÏ£¬ÀûÓÃmodprobe ipv6±ã¿ÉÒÔÒÔÄ£¿éµÄ·½Ê½¼ÓÔØIPv6ЭÒéÕ»¡£±¾Æª½ö½éÉÜlinuxÏÂÃæµÄIPv6ЭÒéÕ»µÄÅäÖÃÃüÁÒÔºó»á½ÐøÍƳö¸üΪÏ꾡µÄlinux¼ ......

linux¼ÜÉèsubversion(svn)°æ±¾¿ØÖÆ


1.ÐèÒªÁ½¸öÎļþ£¬httpdºÍsubversion. httpdÊÇweb·þÎñÆ÷£¬ÓÃÀ´Í¨¹ýweb·ÃÎÊsubversion£¬httpd¿ÉÒÔÔÚapache¹Ù·½ÍøÕ¾ÉÏÏÂÔص½ 
2.н¨Ò»¸öÓû§£ºsvnroot
×îºÃ²»ÒªÈÃrootÓû§²ÎÓëµ½svnµÄȨÏÞ¹ÜÀíºÍÈÕ³£µÄÔËÐкÍά»¤¹¤×÷ÖÐÀ´£¬µ«ÊÇÏÂÃæµÄһЩ°²×°ºÍÅäÖòÙ×÷»¹ÊÇ ÐèÒªrootÓû§À´Íê³ÉµÄ£¬ÒòΪÓÐЩ²Ù×÷Ö»ÓÐroot²ÅÄÜ×ö¡£È¨Ï ......

linux tinyxml±éÀú

·½·¨Ò»¡¢
bool ReadElemnt(string& szFileName)
{
 TiXmlDocument myDocument(szFileName);   
  bool loadOkay = myDocument.LoadFile();
  if(loadOkay == false)
   return false;
 TiXmlElement *rootElement = myDocument.RootElement();
 if(rootEle ......

linux С¼¼ÇÉ

linux С¼¼ÇÉ
Ç°ÑÔ£ºÒòΪÓÃLinuxµÄʱ¼äÔ½À´Ô½³¤£¬ËùÐèÒª×öµÄÊÂÒ²Ô½À´Ô½¶à£¬Ð§ÂʳÉÁËÎÒ±ØÐèÍ»ÆƵÄÆ¿¾±¡£ÔÚ´Ë×ܽáÒ»ÏÂÕâ¶Îʱ¼äÓùýµÄһЩºÃµÄLinux¼¼ÇÉ¡£ÒÔºóʱ³£²¹³äÕâÑù×Ô¼ºÒªÓõÄʱºò¾ÍºÜ·½±ãÁË¡£ Author:Ajian[Îı¾´¦Àí]1¡¢ ...
Ç°ÑÔ£ºÒòΪÓÃLinuxµÄʱ¼äÔ½À´Ô½³¤£¬ËùÐèÒª×öµÄÊÂÒ²Ô½À´Ô½¶à£¬Ð§ÂʳÉÁËÎÒ±ØÐèÍ»ÆƵÄÆ¿¾±¡£ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ