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

Linux select

selectº¯ÊýÊÇÓÃÓÚ³ÌÐò¼àÊÓ¶à¸öÎļþÃèÊö·û(file descrīptor)µÄ״̬±ä»¯¡£³ÌÐò»áÍ£ÔÚselectÕâÀïµÈ´ý£¬Ö±µ½±»¼àÊÓµÄÎļþÃèÊö·ûÓÐijһ¸ö»ò¶à¸ö·¢ÉúÁË״̬¸Ä±ä¡£select()µÄ»úÖÆÖÐÌṩһfd_setµÄÊý¾Ý½á¹¹£¬Êµ¼ÊÉÏÊÇÒ»longÀàÐ͵ÄÊý×飬 ÿһ¸öÊý×éÔªËض¼ÄÜÓëÒ»´ò¿ªµÄÎļþÃèÊö·û£¨²»¹ÜÊÇSocketÃèÊö·û,»¹ÊÇÆäËû Îļþ»òÃüÃû¹ÜµÀ»òÉ豸ÃèÊö·û£©½¨Á¢ÁªÏµ£¬½¨Á¢ÁªÏµµÄ¹¤×÷ÓɳÌÐòÔ±Íê³É£¬ µ±µ÷ÓÃselect()ʱ£¬ÓÉÄں˸ù¾ÝIO״̬ÐÞ¸Äfd_setµÄÄÚÈÝ£¬ÓÉ´ËÀ´Í¨ÖªÖ´ ÐÐÁËselect()µÄ½ø³ÌÄÄÒ»Socket»òÎļþ¿É¶Á.
selectº¯ÊýÔ­ÐÍÈçÏ£º
   int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);
º¯ÊýµÄ×îºóÒ»¸ö²ÎÊýtimeoutÏÔÈ»ÊÇÒ»¸ö³¬Ê±Ê±¼äÖµ£¬ÆäÀàÐÍÊÇstruct timeval *£¬¼´Ò»¸östruct timeval½á¹¹µÄ±äÁ¿µÄÖ¸Õ룬ËùÒÔÎÒÃÇÔÚ³ÌÐòÀïÒªÉêÃ÷Ò»¸östruct timeval tv;È»ºó°Ñ±äÁ¿tvµÄµØÖ·&tv´«µÝ¸øselectº¯Êý£¬Èç¹û×îºóÒ»¸ö³¬Ê±µÄʱ¼äÖµÉèÖÃΪNULL±íʾÎÞ³¬Ê±Ê±¼ä¡£struct timeval½á¹¹ÈçÏ£º
struct timeval
{
long   tv_sec;     /* seconds */
long   tv_usec;    /* microseconds */
};
µÚ2¡¢3¡¢4Èý¸ö²ÎÊýµÄÀàÐÍÊÇÒ»ÑùµÄ£º fd_set *£¬¼´ÎÒÃÇÔÚ³ÌÐòÀïÒªÉêÃ÷¼¸¸öfd_setÀàÐ͵ıäÁ¿£¬±ÈÈ綨ÒåÁËrfds, wfds, efds¡£
ÁíÍâ¹ØÓÚfd_setÀàÐ͵ıäÁ¿£¬»¹ÓÐÒ»×é±ê×¼µÄºê¶¨ÒåÀ´´¦Àí´ËÀà±äÁ¿£º
FD_ZERO(fd_set *fdset)£ºÇå¿ÕfdsetÓëËùÓÐÎļþÃèÊö·ûµÄÁªÏµ¡£
FD_SET(int fd, fd_set *fdset)£º½¨Á¢ÎļþÃèÊö·ûfdÓëfdsetµÄÁªÏµ¡£
FD_CLR(int fd, fd_set *fdset)£ºÇå³ýÎļþÃèÊö·ûfdÓëfdsetµÄÁªÏµ¡£
FD_ISSET(int fd, fd_set *fdset)£º¼ì²éfd_setÁªÏµµÄÎļþÃèÊö·ûfdÊÇ·ñ¿É¶Áд£¬>0±íʾ¿É¶Áд¡£
£¨¹ØÓÚfd_set¼°Ïà¹ØºêµÄ¶¨Òå¼û/usr/include/sys/types.h£©¶¨ÒåµÄÕâÈý¸ö²ÎÊý¶¼ÊÇÃèÊö·ûµÄ¼¯ºÏ£¬µÚÒ»¸örfdsÊÇÓÃÀ´±£´æÕâÑùµÄÃèÊö·ûµÄ£ºµ±ÃèÊö·ûµÄ״̬±ä³É¿É¶ÁµÄʱϵͳ¾Í»á¸æËßselectº¯Êý·µ»Ø£¬µÚ¶þ¸öwfdsÊÇÖ¸ÓÐÃèÊö·û״̬±ä³É¿ÉдµÄʱϵͳ¾Í»á¸æËßselectº¯Êý·µ»Ø£¬µÚÈý¸ö²ÎÊýefdsÊÇÌØÊâÇé¿ö£¬¼´ÃèÊö·ûÉÏÓÐÌØÊâÇé¿ö·¢Éúʱϵͳ»á¸æËßselectº¯Êý·µ»Ø¡£ÏÂÃæÒÔÒ»¸öÊäÈëΪÀýÀ´ËµÃ÷£º
......other codes
int fd1, fd2;         /* ÔÚ¶¨ÒåÁ½¸öÃèÊö·û*/
fd1 = socket(...);    /* ´´½¨socketÁ¬½Ó*/
fd2


Ïà¹ØÎĵµ£º

linux´®¿Ú±à³Ì

linux´®¿Ú±à³Ì£¨Òªµã×ܽᣩ ÊÕ²Ø
´®¿Ú±à³Ì
²éѯӲ¼þµÄ·½Ê½£º²éѯ·½Ê½¡¢ÖжϷ½Ê½¡¢DMA·½Ê½¡£´®¿ÚºÜ¶àÊÇʹÓÃÖжϷ½Ê½£¬ÕâÖÖ·½Ê½Ò»°ãÀ´½²¶ÔCPU±È½ÏÓÐЧ¡£
UARTµÄ²Ù×÷Ö÷Òª°üÀ¨ÒÔϼ¸¸ö²¿·Ö£º
      Êý¾Ý·¢ËÍ£»Êý¾Ý½ÓÊÜ£»²úÉúÖжϣ»²úÉú²¨ÌØÂÊ£»Loopbackģʽ£»ºìÍâģʽ£»×Ô¶¯Á÷¿Øģʽ£»
 &n ......

Linux ÏÂÐéÄâ»ú——Virtual Box½Ì³Ì

    VirtualBox¹Ù·½ÍøÕ¾£ºhttp://www.virtualbox.org/
    ÒÔÏÂΪubuntu Ϊƽ̨µÄ°²×°¡¢ÅäÖá¢Ê¹Óã¬ÆäʵÔÚ¸÷¸ö·¢ÐаæÖеÄʹÓö¼²î²»¶à£¬Ö»ÊÇÔÚÏÂÔصÄʱºòÐèÒªÏÂÔØÏà¶ÔÓ¦Ö÷ϵͳƽ̨µÄ°²×°°ü¼´¿É¡£
    »·¾³ÐèÇó£º
       VirtualBoxÐèÒªker ......

Unix/Linux ϵͳ×Ô¶¯»¯¹ÜÀí:

±¾ÎÄÊÇ Unix/Linux ϵͳ¹ÜÀí×Ô¶¯»¯ÏµÁÐÖеÄһƪ£¬Ö÷Òª½²ÊöÈçºÎʵÏÖ´ÅÅÌ I/O ×Ô¶¯»¯¼à¿Ø¡£
´ÅÅÌ I/O ¼à¿ØÊÇ Unix/Linux ϵͳ¹ÜÀíÖÐÒ»¸ö·Ç³£ÖØÒªµÄ×é³É²¿·Ö¡£Ëü¿ÉÒÔ¼à¿ØÍÌÍÂÁ¿¡¢Ã¿Ãë I/O Êý¡¢´ÅÅÌÀûÓÃÂÊ¡¢·þÎñʱ¼äµÈÐÅÏ¢£¬²¢ÇÒÔÚ·¢ÏÖÒ쳣ʱ£¬·¢Ë͸澯ÐÅÏ¢¸øϵͳ¹ÜÀíÔ±£¬±ãÓÚϵͳ¹ÜÀíÔ±½øÐе÷ÕûÊý¾Ý²¼¾ÖµÈ¹ÜÀí»î¶¯ÒÔ´ïµ½ÓÅ»¯Ï ......

ÔÚmenuconfigÖÐÅäÖÃLinuxÄں˲üôµÄ¾ßÌå²½Öè(2)

µÚ¾Å²¿·Ö£º³ýÒÔÏÂÑ¡ÏÆäËüÈ«²¿É¾³ý
¡¡¡¡Networking
¡¡¡¡Networking options --->
¡¡¡¡[]Unix domain sockets
¡¡¡¡[]TCP/IP networking
µÚÊ®²¿·Ö£º³ýÒÔÏÂÑ¡ÏÆäËüÈ«²¿É¾³ý
¡¡¡¡Device Drivers --->É豸Çý¶¯
¡¡¡¡Block devices-------¡µ
¡¡¡¡[]Compaq SMART2 support
¡¡¡¡[] Compaq Smart Array 5xxx supp ......

Linuxѧϰ±Ê¼Ç

1¡¢ÔÚX11½çÃæÉÏÐÞ¸ÄIPµØÖ·µÈÍøÂçÐÅÏ¢ºó±ØÐëÖØÆôϵͳ²Å»áÉúЧ¡£
2¡¢±àÒëmipsÖ¸Áî³ÌÐòʱ£¬ÓÃmipsel-linux-gccÃüÁîÌáʾmipsel-linux-gcc:command not found£¬¿ÉÒÔÐÞ¸Ä~/.bash_profileÎļþµÄPATH»·¾³±äÁ¿ºóÌí¼Ó:/opt/i686-mipsel-linux-gcc-sdk-3.4.4/cross/bin¡£
¡¡¡¡PATHµÄÖµÊÇһϵÁÐĿ¼£¬µ±ÄúÔËÐÐÒ»¸ö³ÌÐòʱ£¬LinuxÔÚÕâЩ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ