• <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++博客 :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
              32 隨筆 :: 0 文章 :: 25 評(píng)論 :: 0 Trackbacks
            函數(shù)原型 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;  //十秒鐘后將啟動(dòng)定時(shí)器
                tick.it_value.tv_usec = 0;
                tick.it_interval.tv_sec  
            =1//定時(shí)器啟動(dòng)后,每隔1秒將執(zhí)行相應(yīng)的函數(shù)
                tick.it_interval.tv_usec = 0;

                
            //setitimer將觸發(fā)SIGALRM信號(hào)
                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 閱讀(3002) 評(píng)論(0)  編輯 收藏 引用 所屬分類: Linux
            伊人热热久久原色播放www| 成人妇女免费播放久久久| 精品熟女少妇aⅴ免费久久| 亚洲综合精品香蕉久久网97 | 亚洲va久久久噜噜噜久久狠狠 | 久久久久国产一区二区| 久久精品无码专区免费| 亚洲精品国精品久久99热一| 婷婷综合久久狠狠色99h| 青青青青久久精品国产h久久精品五福影院1421| 女同久久| 一本久久a久久精品综合夜夜| 人人妻久久人人澡人人爽人人精品 | 久久婷婷五月综合国产尤物app| 99久久无色码中文字幕| 久久婷婷色香五月综合激情| 高清免费久久午夜精品| 中文字幕无码av激情不卡久久| 日本精品久久久中文字幕| 欧美黑人又粗又大久久久| 日本久久中文字幕| 国产99久久久国产精免费| 久久综合狠狠综合久久| 国内高清久久久久久| 精品国产青草久久久久福利 | 欧美va久久久噜噜噜久久| 久久亚洲av无码精品浪潮| 国产2021久久精品| 国产精品久久久久久搜索 | 国产午夜精品久久久久九九| 久久久久人妻精品一区 | 国产精品久久久久a影院| 国产成人AV综合久久| 久久久久久综合一区中文字幕 | 国産精品久久久久久久| 色综合久久中文色婷婷| 韩国无遮挡三级久久| 狠色狠色狠狠色综合久久| 久久国产亚洲精品麻豆| 亚洲嫩草影院久久精品| A级毛片无码久久精品免费|