NPTL, linuxthreads, and timers

From: Stéphane SARAGAGLIA (saragagliaREMOVEIT_at_ifrance.com)
Date: 12/29/04

  • Next message: vguwdita_at_freedvd.com: "Hot 22 Year Old Looking For Love Or More.....Please Contact Me.......... ON00"
    Date: Wed, 29 Dec 2004 17:47:02 +0100
    
    

    Hi all,

    By testing accuracy of timers, I am using a piece of code wich prints
    the time when a timer signal is received :

    -------------------------- SOURCE BEGIN -----------------------
    #define POSIX_SOURCE 1
    #include <stdio.h>
    #include <stdlib.h>
    #include <signal.h>
    #include <time.h>
    #include <sys/time.h>

    static volatile sig_atomic_t timer_tick = 0;

    void sigalarm(int signo)
    {
         struct timeval time0;
            struct tm *ma_date;

            gettimeofday(&time0, NULL);
            ma_date = localtime( &time0.tv_sec );
            printf("%02d:%02d:%02d.%03d ",
                 ma_date->tm_hour, ma_date->tm_min, ma_date->tm_sec,
                 (unsigned)(time0.tv_usec/1000));
    }

    int main(int argc, char *argv[])
    {
         clock_t clock = CLOCK_REALTIME;
         int signum = SIGRTMAX;
         int microsec = 100000;usec
         int status;
         struct timeval time0, time1;
         double dt;
         timer_t timer_id;
         struct itimerspec ts;
         struct sigevent se;
         struct sigaction act;
         sigset_t sigmask;

         /* Command-line arguments: */
         if (argc >= 2) microsec = atol(argv[1]);

         /* Set up signal handler: */
         sigfillset(&act.sa_mask);
         act.sa_flags = 0;
         act.sa_handler = sigalarm;
         sigaction(signum, &act, NULL);

         /* Set up timer: */
         memset(&se, 0, sizeof(se));
         se.sigev_notify = SIGEV_SIGNAL;
         se.sigev_signo = signum;
         se.sigev_value.sival_int = 0;

         if (timer_create(clock, &se, &timer_id) < 0) {
             perror("timer_create");
             return EXIT_FAILURE;
         }

         /* Start timer: */
         ts.it_interval.tv_sec = microsec / 1000000;
         ts.it_interval.tv_nsec = (microsec % 1000000) * 1000;
         ts.it_value = ts.it_interval;

            if (timer_settime(timer_id, 0, &ts, NULL) < 0) {
             perror("timer_settime");
             return EXIT_FAILURE;
         }

    while (1){
    sleep(10);
    }
         timer_delete(timer_id);

         return EXIT_SUCCESS;
    }
    -------------------------- SOURCE END -----------------------

    When linuxthreads is selected with (setenv LD_ASSUME_KERNEL 2.4.27), the
    display I obtain is (DISPLAY1) :
    -------------------------- DISPLAY1 BEGIN -----------------------
    date :17:25:10.662
    date :17:25:10.762
    date :17:25:10.863
    date :17:25:10.963
    date :17:25:11.063
    date :17:25:11.163
    date :17:25:11.263
    date :17:25:11.363
    date :17:25:11.462
    date :17:25:11.562
    -------------------------- DISPLAY1 END -----------------------

    When NPTL is selected with (setenv LD_ASSUME_KERNEL "" (default)), the
    display I obtain is (DISPLAY2) :
    -------------------------- DISPLAY2 BEGIN -----------------------
    date :17:28:14.203
    date :17:28:14.304
    date :17:28:14.405
    date :17:28:14.506
    date :17:28:14.607
    date :17:28:14.708
    date :17:28:14.809
    date :17:28:14.910
    date :17:28:15.011
    date :17:28:15.112
    -------------------------- DISPLAY2 END -----------------------

    I would like to use NPTL, but the results displayed by DISPLAY2 are
    alarming me... At first sight, we can see it seems there is a
    cummulative time error.

    Could someone tell me more about this ? Is there a error in the source ?
    Is there a problem on librt.so library ?

    Regards


  • Next message: vguwdita_at_freedvd.com: "Hot 22 Year Old Looking For Love Or More.....Please Contact Me.......... ON00"

    Relevant Pages

    • [PATCH 2.6.17.13] display: Driver ks0108 and cfag12864b
      ... Adds support for additional "display" devices, like small LCD screens. ... +void cfag12864b_E(unsigned char _State) ... +void cfag12864b_CS1 ...
      (Linux-Kernel)
    • Re: Paint issues
      ... One text is displayed centered just before to display the virtual keyboard and the other is the message displayed centered when taking in account the keyboard. ... void CxStatic::PreSubclassWindow ... LOGFONT lf; ... void CxStatic::Format(LPCTSTR szFmt, ...) ...
      (microsoft.public.vc.mfc)
    • Re: Paint issues
      ... I use this CStatic as m_ctlText to display a text VERTICALLY CENTERED ... void CxStatic::PreSubclassWindow ... LOGFONT lf; ... void CxStatic::Format(LPCTSTR szFmt, ...) ...
      (microsoft.public.vc.mfc)
    • Paint issues
      ... One text is displayed centered just before to display the virtual keyboard and the other is the message displayed centered when taking in account the keyboard. ... void CxStatic::PreSubclassWindow ... BOOL CxStatic::SetBitmap(UINT nIDResource, ImageSize Emode, COLORREF rgbTransparent) ... void CxStatic::Format(LPCTSTR szFmt, ...) ...
      (microsoft.public.vc.mfc)
    • [PATCH 2/2] display: Driver ks0108 and cfag12864b
      ... Adds support for additional "display" devices, ... +static const unsigned int FirstMinor = 0; ... +void cfag12864b_E(unsigned char _State) ... +void cfag12864b_CS1 ...
      (Linux-Kernel)