C C++ ¶¨Ê±Æ÷ setitime
setitimer()ΪLinuxµÄAPI£¬²¢·ÇCÓïÑÔµÄStandard Library£¬setitimer()ÓÐÁ½¸ö¹¦ÄÜ£¬Ò»ÊÇÖ¸¶¨Ò»¶Îʱ¼äºó£¬²ÅÖ´ÐÐij¸öfunction£¬¶þÊÇÿ¼ä¸ñÒ»¶Îʱ¼ä¾ÍÖ´ÐÐij¸öfunction£¬ÒÔϳÌÐòdemoÈçºÎʹÓÃsetitimer()¡£
/*
Filename : timer.cpp
Compiler : gcc 4.1.0 on Fedora Core 5
Description : setitimer() set the interval to run function
Synopsis : #include <sys/time.h>
int setitimer(int which, const struct itimerval *value, struct itimerval *ovalue);
struct itimerval {
struct timerval it_interval;
struct timerval it_value;
};
struct timeval {
long tv_sec;
long tv_usec;
}
Release : 11/25/2006
*/
#include <stdio.h> // for printf()
#include <unistd.h> // for pause()
#include <signal.h> // for signal()
#include <string.h> // for memset()
#include <sys/time.h> // struct itimeral. setitimer()
void printMsg(int);
int main() {
// Get system call result to determine successful or failed
int res = 0;
// Register printMsg to SIGALRM
signal(SIGALRM, printMsg);
struct itimerval tick;
// Initialize struct
memset(&tick, 0, sizeof(tick));
// Timeout to run function first time
tick.it_value.tv_sec = 1; // sec
tick.it_value.tv_usec = 0; // micro sec.
// Interval time to run function
tick.it_interval.tv_sec = 1;
tick.it_interval.tv_usec = 0;
// Set timer, ITIMER_REAL : real-time to decrease timer,
// send SIGALRM when timeout
res = setitimer(ITIMER_REAL,
Ïà¹ØÎĵµ£º
C/C++ÊÇ×îÖ÷ÒªµÄ±à³ÌÓïÑÔ¡£ÕâÀïÁгöÁË50ÃûÓÅÐãÍøÕ¾ºÍÍøÒ³Çåµ¥£¬ÕâЩÍøÕ¾Ìṩc/c++Ô´´úÂë¡£Õâ·ÝÇåµ¥ÌṩÁËÔ´´úÂëµÄÁ´½ÓÒÔ¼°ËüÃǵÄС˵Ã÷¡£ÎÒÒѾ¡Á¦°üÀ¨×î¼ÑµÄC/C++Ô´´úÂëµÄÍøÕ¾¡£Õâ²»ÊÇÒ»¸öÍêÕûµÄÇåµ¥£¬ÄúÓн¨Òé¿ÉÒÔÁªÏµÎÒ£¬ÎÒ½«»¶ÓÄúµÄ½¨Ò飬ÒÔ½øÒ»²½¼ÓÇ¿Õâ·½ÃæµÄÇåµ¥¡£
1¡¢http://snippets.dzone.com/tag/c/ --ÊýÒÔǧ¼Æ ......
I2CÊÇPhillips¿ª·¢µÄ2ÏߵĴ®ÐÐ×ÜÏßÐÒ顣ͨ³£Ó¦ÓÃÔÚǶÈëʽϵͳÖÐÈò»Í¬µÄ×é¼þͨÐÅ£¬PCÖ÷°å¿ÉÒÔͨ¹ýI2CÀ´Ó벻ͬµÄ´«¸ÐÆ÷ͨÐÅ¡£ÕâЩ´«¸ÐÆ÷ͨ³£±¨¸æ·çÉÈËٶȣ¬´¦ÀíÆ÷ζȺÍÕû¸öÓ²¼þϵͳµÄÐÅÏ¢£¬Õâ¸öÐÒéÒ²¿ÉÒÔÓÃÔÚRAM chipsÉÏ£¬Ïò²Ù×÷ϵͳÌṩDIMMµÄÐÅÏ¢¡£
ÔÚ2.0ʱI2CµÄkernelÔ´Âë²»ÔÚÄÚºËÀïµÄ£¬2.4Äں˰üÀ¨ÁËÒ»µã¶ÔI2CµÄÖ§³Ö ......
1.ÄÚ´æ·ÖÅ䷽ʽ
¡¡¡¡ÄÚ´æ·ÖÅ䷽ʽÓÐÈýÖÖ£º
¡¡¡¡[1]´Ó¾²Ì¬´æ´¢ÇøÓò·ÖÅä¡£ÄÚ´æÔÚ³ÌÐò±àÒëµÄʱºò¾ÍÒѾ·ÖÅäºÃ£¬Õâ¿éÄÚ´æÔÚ³ÌÐòµÄÕû¸öÔËÐÐÆڼ䶼´æÔÚ¡£ÀýÈçÈ«¾Ö±äÁ¿£¬static±äÁ¿¡£
¡¡¡¡[2]ÔÚÕ»ÉÏ´´½¨¡£ÔÚÖ´Ðк¯Êýʱ£¬º¯ÊýÄÚ¾Ö²¿±äÁ¿µÄ´æ´¢µ¥Ôª¶¼¿ÉÒÔÔÚÕ»ÉÏ´´½¨£¬º¯ÊýÖ´ÐнáÊøʱÕâЩ´æ´¢µ¥Ôª×Ô¶¯±»ÊÍ·Å¡£Õ»ÄÚ´æ·ÖÅäÔËËãÄÚÖÃÓÚ ......
¡¡1 ÒýÑÔ
¡¡¡¡Linux²Ù×÷ϵͳÒò¾ßÓÐÔ´´úÂ빫¿ª¡¢±ãÓڲüõ¡¢Óй㷺µÄ´¦ÀíÆ÷Ö§³ÖµÈÓŵ㣬³ÉΪµ±Ç°Ç¶ÈëʽϵͳµÄÈÈÃÅÑ¡Ôñ¡£»ùÓÚI2C×ÜÏߵļüÅÌÀ©Õ¹É豸Ö÷ÒªÓÃÓÚÂú×ãǶÈëʽÉ豸ÖжԶఴ¼üµÄÐèÇó£¬Çý¶¯³ÌÐòÔÚϵͳÆô¶¯Ê±¶ÔÓ²¼þ½øÐгõʼ»¯¡£ÔÚϵͳÆô¶¯ºóʵÏÖÓ²¼þºÍÓ¦ÓóÌÐòÖ®¼äµÄÊý¾Ý½»»¥¡£Õë¶ÔS3C2410΢´¦ÀíÆ÷ºÍ¼üÅÌɨÃè¹ÜÀíÆ÷¼þ£¬É ......
1.Òª½âÎöµÄXMLÎļþÈçÏ£º
<?xml version="1.0" encoding="GB2312"?>
<?xml-stylesheet href="student.xsl" type="text/xsl"?>
<StudentInfo>
<student>
<name>´ïÄÚ</name>
<sex>ÄÐ</sex>
<lesson>
  ......