linux CÕýÔò±í´ïʽ
ÔÚÍøÉÏÕÒµ½µÄÒ»¸ö³ÌÐò
[c]
#include <stdio.h>
#include <sys/types.h>
#include <regex.h>
/* È¡×Ó´®µÄº¯Êý */
static char* substr(const char*str,unsigned start, unsigned end)
{
unsigned n = end - start;
static char stbuf[256];
strncpy(stbuf, str + start, n);
stbuf[n] = 0;
return stbuf;
}
/* Ö÷³ÌÐò */
int main(int argc, char** argv)
{
char * pattern;
int x, z, lno = 0, cflags = 0;
char ebuf[128], lbuf[256];
regex_t reg;
regmatch_t pm[10];
const size_t nmatch = 10;
/* ±àÒëÕýÔò±í´ïʽ*/
pattern = argv[1]; //»ñÈ¡ÕýÔò±í´ïʽ
z = regcomp(®, pattern, cflags); //Èç¹û±àÒë³É¹¦·µ»Ø0,ÆäËü·µ»Ø˵Ã÷ÓдíÎó²úÉú
if (z != 0)
{
regerror(z, ®, ebuf, sizeof(ebuf));
fprintf(stderr, "%s: pattern '%s' \n",ebuf, pattern);
return 1;
}
/* ÖðÐд¦ÀíÊäÈëµÄÊý¾Ý */
while(fgets(lbuf, sizeof(lbuf), stdin))
{
++lno;
//È¡µÃ¶ÁÈ¡×Ö·û´®µÄ³¤¶È£¬²¢ÅжÏ×Ö·û´®½áβ×Ö·ûÊÇ·ñΪ»Ø³µ·û'\n'¡£Èç¹ûÊÇ£¬½«½áβ×Ö·û¸ÄΪ0
if ((z = strlen(lbuf)) > 0 && lbuf[z-1]== '\n')
lbuf[z - 1] = 0;
/* ¶ÔÿһÐÐÓ¦ÓÃÕýÔò±í´ïʽ½øÐÐÆ¥Åä */
z = regexec(®, lbuf, nmatch, pm, 0);
if (z == REG_NOMATCH) continue;
&nbs
Ïà¹ØÎĵµ£º
1¡¢free ²é¿´·þÎñÆ÷µÄÄÚ´æ·ÖÅäÇé¿ö
2¡¢resin ¼ò½é£º
ps -elf|grep java //²é¿´½ø³Ì resinÆô¶¯Çé¿ö
ps -elf|grep java
ll //²é¿´½Å±¾Æô¶¯ÁÐ±í£¨ÒªÆô¶¯µÄÎļþÁÐ±í£©
dl _jsp
// ......
£¨1£©²é¿´Ê±ÖÓÖжϣº
$ cat /proc/interrupts
CPU0
0: 1380471 IO-APIC-edge timer
1: 3626 IO-APIC-edge i8 ......
1.×Ö·ûÉ豸Óë¿éÉ豸IO²Ù×öµÄÇø±ð
1)¿éÉ豸ֻÄÜÒÔ¿éΪµ¥Î»½ÓÊÕÊäÈë·µ»ØÊä³ö,¶ø×Ö·ûÉ豸ÔòÒÔbyteΪµ¥Î».´ó¶àÊýÉ豸ÊÇ×Ö·ûÉ豸,ËûÃDz»ÐèÒª»º³å²¢ÇÒ²»ÒԹ̶¨¿é´óС½øÐвÙ×÷.
2)¿éÉ豸¶ÔÓÚIOÇëÇóÓжÔÓ¦µÄ»º³åÇø,ËùÒÔËûÃÇ¿ÉÒÔÑ¡ÔñÒÔʲô˳Ðò½øÐÐÏìÓ¦.×Ö·ûÉ豸ÎÞÐ뻺³åÇÒ±»Ö±½Ó¶Áд.
3)×Ö·ûÉ豸ֻÄܱ»Ë³Ðò¶Áд, ......
LinuxºËÐļ¸¸öÖØÒª¸úʱ¼äÓйصÄÃû´Ê»ò±äÊý£¬µ×Ͻ«½éÉÜHZ¡¢tickÓëjiffies¡£
£¨1£©HZ
LinuxºËÐÄÿ¸ô¹Ì¶¨ÖÜÆڻᷢ³ötimer interrupt (IRQ 0)£¬HZÊÇÓÃÀ´¶¨ÒåÿһÃëÓм¸´Îtimer interrupts¡£¾ÙÀýÀ´Ëµ£¬HZΪ1000£¬´ú±íÿÃëÓÐ1000´Îtimer interrupts¡£ HZ¿ÉÔÚ±àÒëºËÐ ......
cÓïÑԺ궨ÒåµÄÁ¬½Ó·ûÓÐÄÄЩ
[´ËÎÊÌâµÄÍƼö´ð°¸]
(Ò»)ºê¶¨ÒåÖеÄ## Á¬½Ó·ûÓë# ·û
## Á¬½Ó·ûºÅÓÉÁ½¸ö¾®ºÅ×é³É£¬Æ书ÄÜÊÇÔÚ´ø²ÎÊýµÄºê¶¨ÒåÖн«Á½¸ö×Ó´®(token)Áª½ÓÆðÀ´£¬´Ó¶øÐγÉÒ»¸öеÄ×Ó´®¡£µ«Ëü²»¿ÉÒÔÊǵÚÒ»¸ö»òÕß×îºóÒ»¸ö×Ó´®¡£ËùνµÄ×Ó´®(token)¾ÍÊÇÖ¸±àÒëÆ÷Äܹ»Ê¶±ðµÄ×îСÓï·¨µ¥Ôª¡£¾ßÌåµÄ¶¨ÒåÔÚ±àÒëÔÀíÀïÓÐÏ꾡µÄ ......