• <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
            91精品国产综合久久精品| 久久精品免费一区二区| 久久亚洲精品成人AV| 久久99精品久久久久久动态图| 久久99精品久久久久久久久久| 国产成人精品久久亚洲高清不卡| 国产精品久久久久一区二区三区| 亚洲国产综合久久天堂| 久久精品免费全国观看国产| 久久亚洲国产成人精品性色| 久久久精品久久久久特色影视| 欧美丰满熟妇BBB久久久| 99久久综合国产精品二区| 影音先锋女人AV鲁色资源网久久| 国产ww久久久久久久久久| 亚洲国产一成人久久精品| 久久AⅤ人妻少妇嫩草影院| 久久这里只有精品18| 亚洲国产视频久久| 99久久国产综合精品五月天喷水| 丁香色欲久久久久久综合网| 久久精品一区二区| 久久精品国产网红主播| 亚洲精品国产第一综合99久久| 国内精品久久久久久久久电影网 | 中文字幕精品无码久久久久久3D日动漫 | 久久这里只有精品久久| 97精品伊人久久大香线蕉| 99久久无码一区人妻| 国产精品久久久久久影院 | 久久综合给合久久狠狠狠97色| 日韩欧美亚洲综合久久影院Ds| 99久久综合狠狠综合久久| 久久国产精品久久久| 国产精品久久久久aaaa| 国产精品久久久久久搜索| 久久成人精品视频| 亚洲精品高清国产一久久| 久久国产精品-国产精品| 伊人久久免费视频| 久久人妻少妇嫩草AV蜜桃|