Re: XForms: problem with fl_set_idle_delta in 1.0 RC 5.2

From: Steve Lamont (spl@eggshell.ucsd.edu)
Date: Mon Dec 02 2002 - 20:06:08 EST

  • Next message: Peter S Galbraith: "Re: XForms: problem with fl_set_idle_delta in 1.0 RC 5.2"

    # To subscribers of the xforms list from Steve Lamont <spl@eggshell.ucsd.edu> :

    > I am doing them in the order you suggest. Early on I define
    > #define ANLY_IDLE_DELAY 100
    > #define ANLY_CALC_DELAY 10
    > [. . .]
    > And the whole thing is started by this:
    >
    > void gSetIdleRoutine( VOIDFUNCPTR idlefunc )
    > {
    > runthis = idlefunc;
    > if( runthis == NULL )
    > {
    > fl_set_idle_delta( ANLY_IDLE_DELAY );
    > printf( "Set idle delta to %d\n", ANLY_IDLE_DELAY );
    > }
    > else
    > {
    > fl_set_idle_delta( ANLY_CALC_DELAY );
    > printf( "Set idle delta to %d\n", ANLY_CALC_DELAY );
    > }
    > }

    So the delta is not being set to 0 as you alluded previously (which
    would actually sets the idle delta to 0.1 times the default timer
    resolution, currently 50 milliseconds, or 5 milliseconds).

    > I have looked through the xforms source code and it appears to
    > be setting the correct value, but I have not stepped through it
    > with a debugger. Is there anything else that sets the delta
    > value?

    I suspect that you're running into some form of time granularity
    problem.

    Down deep in asyn_io.c in fl_watch_io() there's call to fl_msleep()
    which, in turn, calls either select() with a timeout or one form or
    another of usleep(), depending on a #define.

    While the timeval structure has microsecond precision, most system
    timers don't.

    My Sun systems give me a maximum of 100 idle function calls per
    second, which squares with a 10 millisecond clock granularity.
    Decreasing the timeout value below 10 milliseconds has no effect.

    FreeBSD gives me even worse timer granularity.

    The following quick and dirty test program demonstrates this.

                                    - - -
    #include <stdio.h>
    #include <stdlib.h>
    #include <sys/time.h>

    int main( int argc, char **argv )

    {

        int tms;
        struct timeval tv0;
        struct timeval tv1;
        struct timeval timeout;

        for ( tms = 1024; tms; tms /= 2 ) {

            timeout.tv_sec = tms / 1000;
            timeout.tv_usec = ( tms % 1000 ) * 1000;

            gettimeofday( &tv0, NULL );
            select( 0, NULL, NULL, NULL, &timeout );
            gettimeofday( &tv1, NULL );

            fprintf( stderr, "timeout = %4d msec, %g msec elapsed\n",
                     tms,
                     ( ( tv1.tv_sec - tv0.tv_sec ) +
                       ( ( tv1.tv_usec - tv0.tv_usec ) * 1.0e-6 ) ) * 1000 );

        }
        exit( 0 );

    }

                                    - - -

    Some time ago I converted all my applications which require
    computation in the background to POSIX threads, which gives me much
    more control.

    > > I'm not sure if you'd call this a bug or a feature. I don't know when
    > > it was changed, offhand.
    >
    > I call it a bug. It violates the rule of least astonishment.

    I'd tend to agree. I'll file this for revision in Version 1.1.

                                                            spl
    _________________________________________________
    To unsubscribe, send the message "unsubscribe" to
    xforms-request@bob.usuhs.mil or see
    http://bob.usuhs.mil/mailserv/xforms.html
    XForms Home Page: http://world.std.com/~xforms
    List Archive: http://bob.usuhs.mil/mailserv/list-archives/



    This archive was generated by hypermail 2b29 : Mon Dec 02 2002 - 20:07:16 EST