• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            Jiwu Bu

              C++博客 :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
              32 隨筆 :: 0 文章 :: 25 評論 :: 0 Trackbacks
            函數原型 int setitimer(int which, const struct itimerval *value,
                                 struct itimerval *ovalue);

            DESCRIPTION
                   The  system  provides each process with three interval timers, each decrementing in a distinct time domain.  When any timer expires, a
                   signal is sent to the process, and the timer (potentially) restarts.

                   ITIMER_REAL    decrements in real time, and delivers SIGALRM upon expiration.

                   ITIMER_VIRTUAL decrements only when the process is executing, and delivers SIGVTALRM upon expiration.

                   ITIMER_PROF    decrements both when the process executes and when the system is executing on behalf  of  the  process.   Coupled  with
                                  ITIMER_VIRTUAL, this timer is usually used to profile the time spent by the application in user and kernel space.  SIG-
                                  PROF is delivered upon expiration.

                   Timer values are defined by the following structures:

                        struct itimerval {
                            struct timeval it_interval; /* next value */
                            struct timeval it_value;    /* current value */
                        };
                        struct timeval {
                            long tv_sec;                /* seconds */
                            long tv_usec;               /* microseconds */
                        };

            #include <stdio.h>
            #include 
            <unistd.h>
            #include 
            <signal.h>
            #include 
            <string.h>
            #include 
            <sys/time.h>
            #include 
            <errno.h>

            void PrintMsg(int Num)
            {
                printf(
            "%s\n""Hello World");

                
            return;
            }

            int main(int argc, char* argv[])
            {
                signal(SIGALRM, PrintMsg);

                
            struct itimerval tick;
                tick.it_value.tv_sec 
            = 10;  //十秒鐘后將啟動定時器
                tick.it_value.tv_usec = 0;
                tick.it_interval.tv_sec  
            =1//定時器啟動后,每隔1秒將執行相應的函數
                tick.it_interval.tv_usec = 0;

                
            //setitimer將觸發SIGALRM信號
                int ret = setitimer(ITIMER_REAL, &tick, NULL);

                
            if ( ret != 0)
                {
                    printf(
            "Set timer error. %s \n", strerror(errno) );

                    
            return -1;
                }

                printf(
            "Wait!\n");

                getchar();

                
            return 0;
            }

            posted on 2009-11-16 13:50 bujiwu 閱讀(3007) 評論(0)  編輯 收藏 引用 所屬分類: Linux
            亚洲欧美日韩久久精品| 亚洲精品乱码久久久久久久久久久久 | 久久久久无码国产精品不卡| 亚洲伊人久久大香线蕉苏妲己| 国产精品伦理久久久久久 | 亚洲美日韩Av中文字幕无码久久久妻妇 | 偷偷做久久久久网站| 欧美噜噜久久久XXX| 久久国产精品一区| 亚洲中文字幕无码一久久区| 久久国产精品成人片免费| 久久WWW免费人成—看片| 中文字幕乱码久久午夜| 伊人久久免费视频| 亚洲色欲久久久综合网| 香港aa三级久久三级| 久久天堂电影网| 成人精品一区二区久久久| 91麻精品国产91久久久久| 国产成人综合久久精品尤物| 国内精品久久人妻互换| 久久久久99这里有精品10| 精品久久久久久国产潘金莲| 看全色黄大色大片免费久久久| 丰满少妇人妻久久久久久 | 日韩亚洲欧美久久久www综合网 | 欧美性大战久久久久久| 久久精品国产69国产精品亚洲| 一本色道久久99一综合| 午夜精品久久影院蜜桃| 99久久国产亚洲高清观看2024| 久久久久久久久久久久中文字幕 | 久久99精品国产自在现线小黄鸭 | 久久无码高潮喷水| 久久人人爽人人爽人人片AV麻豆| 丁香五月网久久综合| 欧美牲交A欧牲交aⅴ久久| 精品无码久久久久久午夜| 青青草原精品99久久精品66| 久久亚洲sm情趣捆绑调教| 午夜精品久久久久|