• <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 閱讀(3003) 評論(0)  編輯 收藏 引用 所屬分類: Linux
            97久久精品国产精品青草| 午夜视频久久久久一区 | a级成人毛片久久| 亚洲精品高清久久| 亚洲国产香蕉人人爽成AV片久久| 中文字幕乱码人妻无码久久| 国产精品久久免费| 色欲综合久久躁天天躁| 久久国产精品无码一区二区三区| 国产亚洲精久久久久久无码AV| 亚洲国产精品无码久久青草| 久久精品欧美日韩精品| 久久免费香蕉视频| www久久久天天com| 色综合久久夜色精品国产| 久久香蕉超碰97国产精品| 欧美麻豆久久久久久中文| 久久国产精品99国产精| 久久精品桃花综合| 国内精品欧美久久精品| 国产成人久久AV免费| 一本色道久久综合| 久久久99精品成人片中文字幕 | 久久久久久久综合综合狠狠| 久久夜色精品国产噜噜麻豆 | 国产亚洲欧美成人久久片| 久久伊人精品一区二区三区| 久久精品国产亚洲欧美| 久久亚洲精品人成综合网| 东方aⅴ免费观看久久av| 久久无码人妻精品一区二区三区| 91精品国产91热久久久久福利| 久久久噜噜噜久久中文福利| 精品综合久久久久久97| 久久精品国产久精国产果冻传媒| 青青久久精品国产免费看| 久久精品18| 久久频这里精品99香蕉久| 中文字幕精品久久久久人妻| 一本久久综合亚洲鲁鲁五月天亚洲欧美一区二区 | 国产精品一区二区久久精品|