• <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
            久久99久国产麻精品66| 久久精品国产男包| 国产精品久久久久久久久鸭| 99久久精品国产免看国产一区| 久久亚洲私人国产精品| 久久伊人亚洲AV无码网站| 国产三级久久久精品麻豆三级| 无码国内精品久久人妻麻豆按摩| 久久国产精品成人片免费| 久久WWW免费人成一看片| 亚洲αv久久久噜噜噜噜噜| 久久精品国产精品亚洲人人| 俺来也俺去啦久久综合网| 大香网伊人久久综合网2020| 2020久久精品国产免费| 久久久久国产精品三级网| 久久99精品久久久久久久不卡| 久久精品国产亚洲AV不卡| 久久综合国产乱子伦精品免费| 久久精品国产色蜜蜜麻豆| 午夜精品久久久久久中宇| 久久久久这里只有精品 | 国产A级毛片久久久精品毛片| 亚洲伊人久久综合影院| 久久影院午夜理论片无码| 99久久免费国产精精品| 伊人久久精品无码av一区| 久久SE精品一区二区| 日本精品久久久久久久久免费| 人人狠狠综合久久亚洲88| 亚洲国产精品久久久久| 一本伊大人香蕉久久网手机| 久久久久99精品成人片欧美| 久久综合久久美利坚合众国| 久久综合亚洲色HEZYO社区| 久久er国产精品免费观看8| 久久久久久青草大香综合精品| 久久综合中文字幕| 99久久精品国产综合一区| 国产精品99久久久久久宅男| 国产精品亚洲美女久久久|