• <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
            久久综合给久久狠狠97色| 无码国内精品久久人妻蜜桃| 99久久成人18免费网站| 91久久精品视频| 久久婷婷人人澡人人爽人人爱| 国内精品综合久久久40p| 97r久久精品国产99国产精| 国产三级观看久久| 2021国产精品午夜久久| 97久久精品人妻人人搡人人玩 | 久久久久亚洲av成人无码电影| 久久99精品国产麻豆不卡| 国产精品九九久久免费视频 | 99久久精品九九亚洲精品| 亚洲精品乱码久久久久久不卡| 久久精品国产AV一区二区三区| 久久精品国产只有精品2020| 久久综合九色欧美综合狠狠| 久久人人妻人人爽人人爽| 国产高清美女一级a毛片久久w| 久久人人爽人人爽人人片av麻烦| 97久久香蕉国产线看观看| 欧美国产成人久久精品| 久久精品国产影库免费看| 天堂久久天堂AV色综合| 精品久久久久中文字幕一区| 久久久久久亚洲AV无码专区| 色综合久久天天综线观看| 色综合久久天天综合| 色综合久久无码五十路人妻| 无码8090精品久久一区| 久久精品成人影院| 久久精品视频网| 久久99精品国产麻豆宅宅| 少妇高潮惨叫久久久久久| 东方aⅴ免费观看久久av| 亚洲精品乱码久久久久久蜜桃| 久久久久久国产精品无码下载| 日本三级久久网| 国产伊人久久| 色婷婷狠狠久久综合五月|