setitimer()

Claus, Ric claus at slac.stanford.edu
Fri Dec 20 19:50:53 UTC 2013


A program that I’m trying to make compatible with RTEMS (iperf 2.0.5) uses the posix function setitimer(), which has only a trivial implementation under RTEMS.  I modified the code as follows:

    if ( mMode_Time ) {
	memset (&it, 0, sizeof (it));
	it.it_value.tv_sec = (int) (mSettings->mAmount / 100.0);
	it.it_value.tv_usec = (int) 10000 * (mSettings->mAmount -
	    it.it_value.tv_sec * 100.0);
#ifndef __rtems__
	err = setitimer( ITIMER_REAL, &it, NULL );
	if ( err != 0 ) {
	    perror("setitimer");
	    exit(1);
	}
#else
        FAIL (mSettings->mAmount > UINT_MAX / 10000, "ualarm", mSettings);

        ualarm(mSettings->mAmount * 10000, 0);
#endif
    }

If implementing setitimer( ITIMER_REAL, … ) with ualarm() is a valid thing to do (please comment), would it be useful for me to provide a patch to setitimer() that operates this way?  I’m not sure whether in this scenario the alarm must be cancelled with alarm(0, 0) later or not, but that would prevent this from being a generic solution.

	Cheers,
			Ric



More information about the devel mailing list