LinuxÉ豸Çý¶¯¿ª·¢Ïê½â ±Ê¼Ç9 Ò첽֪ͨÓëÒì²½I/O
Ò첽֪ͨ£ºÒ»µ©É豸¾ÍÐ÷£¬ÔòÖ÷¶¯Í¨ÖªÓ¦ÓóÌÐò£¬ÕâÑùÓ¦ÓóÌÐò¸ù±¾²»ÐèÒª²éѯÉ豸״̬£¬ÕâÒ»µã·Ç³£ÀàËÆÓÚÓ²¼þÉϵēÖжϔµÄ¸ÅÄ±È½Ï׼ȷµÄ³ÆνÊÇ“ÐźÅÇý¶¯µÄÒì²½I/O
//Æô¶¯ÐźÅÇý¶¯»úÖÆ
signal(SIGIO, input_handler);//ÈÃinput_handler()´¦ÀíSIGIOÐźÅ
fcntl(fd, F_SETOWN, getpid());//ÉèÖñ¾½ø³ÌΪSTDIN_FILENOÎļþµÄÓµÓÐÕߣ¬ÈÃÄÚºËÖªµÀ½«Ðźŷ¢¸ø±¾½ø³Ì
oflags = fcntl(fd, F_GETFL);//ÏÂÃæÁ½¾ä£ºÉèÖÃFASYNC±êÖ¾£¬Æô¶¯Ò첽֪ͨ±êÖ¾
fcntl(fd, F_SETFL, oflags | FASYNC);
É豸Çý¶¯ÖÐÒ첽֪ͨ±à³Ì±È½Ï¼òµ¥£¬Ö÷ÒªÓõ½Ò»ÏîÊý¾Ý½á¹¹ºÍÁ½¸öº¯Êý
Êý¾Ý½á¹¹£º
struct xxx_dev
{
Struct cdev cdev;
……
Struct fasync_struct *async_queue;
}
Int fasync_helper(int fd, struct file *filp, int mode, struct fasync_struct **fa);
Void kill_fasync(struct fasync_struct **fa, int sig, int band);
static int globalfifo_fasync(int fd, struct file *filp, int mode)
{
struct globalfifo_dev *dev = filp->private_data;
return fasync_helper(fd, filp, mode, &dev->async_queue);
}
static ssize_t globalfifo_write(struct file *filp, const char __user *buf,
size_t count, loff_t *ppos)
{
struct globalfifo_dev *dev = filp->private_data; //»ñµÃÉ豸½á¹¹ÌåÖ¸Õë
……
if (dev->async_queue)
kill_fasync(&dev->async_queue, SIGIO, POLL_IN);
ret = count;
}
int globalfifo_release(struct inode *inode, struct file *filp)
{
globalfifo_fasync( - 1, filp, 0);
return 0;
}
AIO»ù±¾Ë¼ÏëÊÇÔÊÐí½ø³Ì·¢ÆðºÜ¶àI/O²Ù×÷£¬¶ø²»ÓÃ×èÈû»òµÈ´ýÈκβÙ×÷Íê³É
Òì²½IOºÍ±ê×¼IOÖ®¼äµÄÁíÒ»¸öÇø±ðÊDz»ÄÜÁ¢¼´·ÃÎÊÕâ¸öº¯ÊýµÄ·µ»Ø״̬£¬ÒòΪ²¢Ã»ÓÐ×èÈûÔÚread()µ÷ÓÃÉÏ¡£ÔÚ±ê×¼µÄread()µ÷ÓÃÖУ¬·µ»Ø״̬ÊÇÔڸú¯Êý·µ»ØʱÌṩµÄ£¬µ«ÊÇÔÚÒì²½IOÖУ¬ÎÒÃÇҪʹÓÃaio_return()º¯Êý£¬Ö»ÓÐÔÚaio_error()µ÷
Ïà¹ØÎĵµ£º
×ÜÀÀ
ÓÃiptables -ADC À´Ö¸¶¨Á´µÄ¹æ
Ôò
£¬-AÌí¼Ó -Dɾ³ý -C ÐÞ¸Ä
iptables - [RI] chain rule num rule-specification[option]
ÓÃiptables - RI ͨ¹ý¹æÔòµÄ˳ÐòÖ¸¶¨
iptables -D chain rule num[option]
ɾ³ýÖ¸¶¨¹æÔò
iptables -[LFZ] [chain][option]
ÓÃiptables -LFZ Á´Ãû [Ñ¡Ïî]
iptables -[NX] chain
ÓÃ -NX ......
Author-------Dansen-----xzd2734@163.com
wait_queue_head_t wait_q;
Ê×ÏÈ¿´¿´
wait_queue_head_tÕâ¸öµÈ´ý¶ÓÁеĽṹ
ÔÚwait.hÖж¨ÒåÁËÕâ¸ö½á¹¹
typedef struct
__wait_queue_head wait_queue_head_t;
struct __wait_queue_head {
wq_lock_t
lock;
struct list_head task_list;
};
# define wq_ ......
#include <iostream>
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <signal.h>
using namespace std;
extern char **environ;
void signal_handle(int signal_no){
cout << "sign:" &l ......
´ÓÕâ¸ö×ܽáÕýʽ¿ªÊ¼ÁËÎÒµÄÇý¶¯Ö®Âã¬ÐÄÇé²»ÃâÓе㼤¶¯£¬¾¡¹ÜÏÖÔÚ¶ÔÇý¶¯µÄ±àд»¹ºÜÄ£ºý£¬µ«»¹ÊÇÓмÍÄîÒâÒåµÄ……
¿ª·¢Æ½Ì¨£º
ÐéÄâ»úÏÂRedHat9£¬ÄÚºË2.4.20.8
½»²æ±àÒë±àÒëÆ÷£ºÌìǶ¹«Ë¾ÌṩµÄarm-linux-gcc 4.3.3
ÄÚºËÊ÷£º/h ......
ʲôÊÇÇý¶¯£¿
×îͨË׵ĽâÊ;ÍÊÇ“ÇýʹӲ¼þÉ豸Ðж¯”
×÷Óã¿
É豸Çý¶¯Óëµ×²ãÓ²¼þÖ±½Ó´ò½»µÀ£¬°´ÕÕÓ²¼þÉ豸µÄ¾ßÌ幤×÷·½Ê½¶ÁдÉ豸¼Ä´æÆ÷£¬Íê³ÉÉ豸µÄÂÖѯ¡¢Öжϴ¦Àí¡¢DMAͨÐÅ£¬½øÐÐÎïÀíÄÚ´æÏòÐéÄâÄÚ´æµÄÓ³É䣬×îÖÕʹͨÐÅÉ豸Äܹ»ÊÕ·¢Êý¾Ý£¬Ê¹ÏÔʾÉ豸Äܹ»ÏÔʾÎÄ×ֺͻÃ棬ʹ´æ´¢É豸Äܹ»¼Ç¼ÎļþºÅÊý¾Ý
¼ÆË ......