• <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 閱讀(3007) 評論(0)  編輯 收藏 引用 所屬分類: Linux
            久久91精品国产91久| 久久99精品国产麻豆宅宅| 97久久超碰国产精品2021| 国产午夜福利精品久久2021 | 91精品国产91久久久久久青草 | 婷婷久久综合九色综合绿巨人| 狠狠精品干练久久久无码中文字幕| 久久国产精品免费| 久久香蕉超碰97国产精品| 成人国内精品久久久久一区| 久久精品中文字幕一区| 亚洲欧美日韩中文久久| 精品久久久久久无码免费| 亚洲国产精品无码久久久不卡| 91久久国产视频| 精品久久久久久国产潘金莲 | 久久精品亚洲福利| 国内精品久久久久影院老司| 欧美亚洲色综久久精品国产| 精品久久综合1区2区3区激情| 久久亚洲精品成人AV| 久久久久亚洲精品天堂久久久久久| 久久亚洲精品中文字幕| 久久99热这里只有精品66| 精品99久久aaa一级毛片| 国产精品久久久久久福利漫画| 区亚洲欧美一级久久精品亚洲精品成人网久久久久 | 国产69精品久久久久APP下载| 国产精品久久久天天影视| 久久久久久久久久久| 超级碰碰碰碰97久久久久| 色婷婷综合久久久久中文字幕| 久久AAAA片一区二区| 伊人久久大香线蕉影院95| 国产精品久久久久久福利69堂| 精品人妻久久久久久888| 无码人妻久久久一区二区三区| A级毛片无码久久精品免费| 女同久久| 久久精品国产清自在天天线| 亚洲精品国产第一综合99久久|