• <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
            影音先锋女人AV鲁色资源网久久| 国产综合久久久久| 伊人久久五月天| 久久久久亚洲AV无码麻豆| 久久精品国产精品亚洲精品| 亚洲精品国产自在久久| 人妻精品久久无码专区精东影业| 久久精品国产国产精品四凭| 亚洲AV日韩精品久久久久| 国产精品热久久无码av| 国产午夜免费高清久久影院| 性做久久久久久免费观看| 久久久青草久久久青草| 狼狼综合久久久久综合网| 亚洲精品高清一二区久久| 国产69精品久久久久9999| 国产综合久久久久| 97久久精品无码一区二区天美| 色狠狠久久综合网| 久久毛片一区二区| 亚洲精品无码久久久久AV麻豆| 99久久人人爽亚洲精品美女| AV狠狠色丁香婷婷综合久久| 一本一道久久综合狠狠老| 久久人人爽人人爽人人片AV东京热| 久久高清一级毛片| 久久久久无码中| 三级片免费观看久久| 精品欧美一区二区三区久久久| 亚洲午夜精品久久久久久人妖| 久久亚洲精品视频| 亚洲国产成人久久综合碰碰动漫3d| 91精品国产综合久久婷婷| 久久男人Av资源网站无码软件| 亚洲欧美日韩久久精品第一区| 久久久久久亚洲Av无码精品专口| 久久无码人妻一区二区三区| 韩国免费A级毛片久久| 久久午夜电影网| 久久久久久无码国产精品中文字幕 | 久久精品国产亚洲7777|