LinuxϽø³Ì¼äͨÐÅ»úÖÆ£ºFIFO£¨ÃüÃû¹ÜµÀ£©
FIFO
£¬ÓÖ³ÆÃüÃû¹ÜµÀ
£¬ÊÇLinuxÏ£¨unix»·¾³Ï£©Ò»ÖÖ½ø³Ì¼äͨÐŵĻúÖÆ£¬Ó¦Óù㷺¡£
º¯Êýmkfifo
ÓÃÓÚ´´½¨ÃüÃû¹ÜµÀ£¬Ê¹ÓÃÃüÁîman 3 mkfifo
¿É²é¿´´Ëº¯ÊýÐÅÏ¢¡£
FIFO´´½¨ºó£¬¿ÉÒÔÏñÆÕͨÎļþÒ»Ñù¶ÔÆä·ÃÎÊ¡£
LinuxÏÂÒ»¸öͬÃûÃüÁîmkfifo
Ò²ÓÃÓÚ´´½¨FIFO£¬ÀýÈ磺
Ö´ÐÐÃüÁî
$ mkfifo /tmp/fifo
$ cat /tmp/fifo
³ÌÐò×èÈû¡£
ÔÙ´ò¿ªÒ»¸öshell£¬Ö´ÐÐ
$ echo hello > /tmp/fifo
Ç°Ò»¸ö³ÌÐò·µ»Ø£¬ÏÔʾhello
ÏÂÃæÓÃÒ»¸ö¼òµ¥³ÌÐò£¬ÑÝʾFIFO IPCµÄÓ÷¨¡£
ÏÂÔصØÖ·£ºhttp://download.csdn.net/source/2378181
¸Ã³ÌÐò·ÖΪ£²¶Ë£º
server³ÌÐò´´½¨Ò»¸öFIFO£¬²¢´ÓFIFO¶ÁÈ¡×Ö·û£¬×ª»»³É´óдºóÊä³öµ½ÆÁÄ»¡£
client³ÌÐò¶ÁÈ¡Óû§ÊäÈ벢дÈëFIFO¡£
common.h
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#define FIFO_PATH "/tmp/myfifo"
server.c
/*
*½«´ÓFIFOÊÕµ½µ½Êý¾Ý£¨×Ö·û£©×ª»»Îª´óд£¬²¢Êä³öµ½ÆÁÄ»
*/
#include "common.h"
int main()
{
int ret;
int fd;
char buffer;
int nread;
int i;
/*½¨Á¢FIFO*/
ret = mkfifo(FIFO_PATH, 0777);
/*´ò¿ªFIFO*/
fd = open(FIFO_PATH, O_RDONLY);
if(-1 == fd)
{
printf("error\n");
return -1;
}
while(1)
{
nread = read(fd, &buffer, 1);
if(nread > 0)
{
buffer = toupper(buffer);
printf("%c", buffer);
}
}
}
ÔËÐÐserverºó£¬¿É¿´µ½´´½¨ÁËÎļþ/tmp/myfifo£¬ÕâÊÇmkfifoº¯ÊýÖ¸¶¨µÄÃüÃû¹ÜµÀµÄ·¾¶£¨Ãû×Ö£©¡£
µ±È»£¬ÏµÍ³²»»áÕæµÄÔÚ´ÅÅÌÉÏ´´½¨Õâ¸öÎļþ¡£
client.c
/*
*¶ÁÈ¡ÊäÈ룬²¢Ð´ÈëFIFO
*/
#include "common.h"
int main()
{
int fd;
int ret;
char c;
fd = open(FIFO_PATH, O_WRONLY);
if(-1 == fd)
{
printf("error\n");
return -1;
}
while(c = getchar())
{
write(fd, &c, 1);
}
}
ÏÈÆô¶¯server³ÌÐò£¬ÔÙÔËÐÐclient£¬Ëæ±ãÊäÈëЩ×Ö·û¡£
server¶Ë½«ÔÚÆÁÄ»ÉÏÏÔʾת»»Îª´óдºóµÄÊäÈë×Ö·û¡£
×÷ÕߣºZhengZhiren
ÔÎÄÁ´½Ó£ºhttp://blog.csdn.net/ZhengZhiRen/archive/2010/05/21/5613843.aspx
Ïà¹ØÎĵµ£º
×ÜÀÀ
ÓÃ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 ......
Ò»¡¢Linux
²é¿´cpuÐÅÏ¢£º
[junjie2@ljj ~]$ cat /proc/cpuinfo
¶þ¡¢Freebsd
dmesg ×î¼òµ¥µÄ·½·¨
freebsd# cat /var/run/dmesg.boot |grep CPU ¿ÉÒԲ鿴 cpuÐÅÏ¢
sysctl hw.model ¿´cpuid
sysctl machdep.tsc_freq ¿´cpuƵÂÊ
# sysctl -a | egrep -i 'hw.machine|hw.model|hw.ncpu'
# dmesg | grep -i cpu ......
¹¦ÄÜÃèÊö£º
»ñÈ¡»òÕßÉèÖÃÓëij¸öÌ×½Ó×Ö¹ØÁªµÄÑ¡ ÏѡÏî¿ÉÄÜ´æÔÚÓÚ¶à²ãÐÒéÖУ¬ËüÃÇ×Ü»á³öÏÖÔÚ×îÉÏÃæµÄÌ×½Ó×ֲ㡣µ±²Ù×÷Ì×½Ó×ÖÑ¡Ïîʱ£¬Ñ¡ÏîλÓڵIJãºÍÑ¡ÏîµÄÃû³Æ±ØÐë¸ø³ö¡£ÎªÁ˲Ù×÷Ì×½Ó×Ö²ãµÄÑ¡ÏӦ¸Ã ½«²ãµÄÖµÖ¸¶¨ÎªSOL_SOCKET¡£ÎªÁ˲Ù×÷ÆäËü²ãµÄÑ¡Ï¿ØÖÆÑ¡ÏîµÄºÏÊÊÐÒéº ......
ÓÉÓÚÎÒÔÚÍøÉÏÏÂÔØÁËUbuntu LinuxÀ´°²×°·¢ÏÖÊÖͷû¿Õ°×¹âÅ̼̿cd,ËùÓÐgoogleÁËÏÂÕÒµ½ÁËÈçÏÂÎÄÕ½øÐÐʵ¼ù. ===================½Ì³Ì1========================== ˵µ½°²×°²Ù×÷ϵͳ£¬´ó¶àÊýÈËÊìϤµÄÊÇ´Ó¹âÅÌÒýµ¼£¬Æäʵ´ÓºÜ¶à´æ´¢É豸¶¼¿ÉÒÔʵÏÖϵͳÒýµ¼µÄ¡£ÓÉÓÚLinux²Ù×÷ϵͳµÄ·¢²¼ºÜ¶à£¬¶ø¶àÊýÈ˶¼ÊÇͨ¹ýÍøÂçÏÂÔزÙ×÷ϵͳµ ......
ÔÚÇ°ÃæµÄÎÄÕÂÖÐÌá¼°µ½£¬Ò»¸ö½ø³ÌÖеĶà¸öÏß³ÌÊǹ²Ïíͬһ¶Î×ÊÔ´µÄ£¬ÓÉÓÚÏ̶߳Ô×ÊÔ´µÄ¾ºÕùÒý³öÁËËø¡£ÆäÖÐmutexÊÇÒ»ÖÖ¼òµ¥µÄ¼ÓËø·½·¨£¬Õâ¸ö»¥³âËøÖ»ÓÐÁ½ÖÖ״̬£¬ÄǾÍÊÇÉÏËøºÍ½âËø£¬¿ÉÒÔ°Ñ»¥³âËø¿´×÷ÊÇijÖÖÒâÒåÉϵÄÈ«¾Ö±äÁ¿¡£ÔÚijһʱ¿Ì£¬Ö»ÄÜÓÐÒ»¸öÏß³ÌÈ¡µÃÕâ¸ö»¥³âÉϵÄËø£¬ÓµÓÐÉÏËø״̬µÄÏ߳̿ÉÒÔ¶Ô¹²Ïí×ÊÔ´½øÐвÙ×÷£¬¶øÆäË ......