• <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
            久久午夜免费视频| 国产精品一久久香蕉国产线看观看| 久久天天躁狠狠躁夜夜躁2014| 久久人人爽人人精品视频| 久久综合久久综合亚洲| 狠狠色丁香久久婷婷综合| 久久精品国产亚洲沈樵| 久久精品国产清自在天天线| 熟妇人妻久久中文字幕| 色诱久久av| 久久国产热这里只有精品| 囯产精品久久久久久久久蜜桃| 久久99国产精一区二区三区| 亚洲日本va午夜中文字幕久久 | 亚洲午夜久久久久久久久电影网| 97久久国产亚洲精品超碰热| 久久久久久青草大香综合精品| 久久九九兔免费精品6| 色综合久久天天综合| 人妻无码久久精品| 天天久久狠狠色综合| 亚洲va久久久噜噜噜久久男同| 久久人人超碰精品CAOPOREN| 久久精品www| 久久国产精品77777| 久久精品国产福利国产秒| 国产成人精品综合久久久久| 久久一区二区三区免费| 国产福利电影一区二区三区久久久久成人精品综合 | 亚洲精品视频久久久| 久久91精品国产91久久麻豆| 影音先锋女人AV鲁色资源网久久| 三级片免费观看久久| 狠狠精品干练久久久无码中文字幕| 91精品国产高清久久久久久91 | 久久婷婷色香五月综合激情| 久久本道久久综合伊人| 久久久久亚洲AV无码专区网站| 久久免费视频一区| 国产99久久久国产精品小说| 色欲综合久久躁天天躁蜜桃|