• <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 閱讀(3009) 評論(0)  編輯 收藏 引用 所屬分類: Linux
            久久不见久久见免费视频7| 婷婷综合久久狠狠色99h| 欧美午夜A∨大片久久 | 久久综合久久鬼色| 伊人伊成久久人综合网777| 伊人久久大香线蕉av不变影院| 久久综合给合久久狠狠狠97色| 99久久国产热无码精品免费久久久久| 天堂无码久久综合东京热| 久久超碰97人人做人人爱| 久久伊人亚洲AV无码网站| 久久不射电影网| 久久人人爽人人爽人人AV| 九九久久精品无码专区| 久久九九青青国产精品| 色综合久久中文字幕综合网| 77777亚洲午夜久久多喷| 国产成人综合久久精品红| 久久九九全国免费| 久久大香香蕉国产| 伊人久久大香线蕉亚洲| 综合久久一区二区三区 | 久久人人爽人人爽人人AV | 日韩人妻无码精品久久久不卡| 国产精品九九久久精品女同亚洲欧美日韩综合区 | 曰曰摸天天摸人人看久久久| 人妻无码αv中文字幕久久| 久久这里有精品| 日韩欧美亚洲国产精品字幕久久久| 久久96国产精品久久久| 狠狠88综合久久久久综合网| 久久永久免费人妻精品下载| 中文字幕热久久久久久久| 国产香蕉久久精品综合网| 亚洲精品97久久中文字幕无码| 久久久久人妻精品一区三寸蜜桃| 久久精品国产亚洲网站| 国产精品嫩草影院久久| 久久久久一级精品亚洲国产成人综合AV区| 亚洲午夜久久影院| 久久最新免费视频|