diff options
author | Jennifer Averett <Jennifer.Averett@OARcorp.com> | 2007-12-20 18:11:24 +0000 |
---|---|---|
committer | Jennifer Averett <Jennifer.Averett@OARcorp.com> | 2007-12-20 18:11:24 +0000 |
commit | 090edf39013e81579f0cdd9c2456c7a411f883d0 (patch) | |
tree | 1679d86ab3ad209e0ed4b1965183def9da0cb301 | |
parent | New. (diff) | |
download | rtems-090edf39013e81579f0cdd9c2456c7a411f883d0.tar.bz2 |
2007-12-20 Jennifer Averett <jennifer.averett@OARcorp.com>
* posix/src/ualarm.c: Fixed bug where iteration did not work correctly.
-rw-r--r-- | cpukit/ChangeLog | 4 | ||||
-rw-r--r-- | cpukit/posix/src/ualarm.c | 33 |
2 files changed, 30 insertions, 7 deletions
diff --git a/cpukit/ChangeLog b/cpukit/ChangeLog index 8c9cce16b1..62e94169b1 100644 --- a/cpukit/ChangeLog +++ b/cpukit/ChangeLog @@ -1,3 +1,7 @@ +2007-12-20 Jennifer Averett <jennifer.averett@OARcorp.com> + + * posix/src/ualarm.c: Fixed bug where iteration did not work correctly. + 2007-12-19 Joel Sherrill <joel.sherrill@OARcorp.com> * sapi/include/confdefs.h: Revert. Requires info not available at diff --git a/cpukit/posix/src/ualarm.c b/cpukit/posix/src/ualarm.c index a5a8ee926b..1de1621b1a 100644 --- a/cpukit/posix/src/ualarm.c +++ b/cpukit/posix/src/ualarm.c @@ -35,10 +35,16 @@ void _POSIX_signals_Ualarm_TSR( void *argument ) { - int status; - - status = kill( getpid(), SIGALRM ); - /* XXX can't print from an ISR, should this be fatal? */ + /* + * Send a SIGALRM but if there is a problem, ignore it. + * It's OK, there isn't a way this should fail. + */ + (void) kill( getpid(), SIGALRM ); + + /* + * If the reset interval is non-zero, reschedule ourselves. + */ + _Watchdog_Reset( &_POSIX_signals_Ualarm_timer ); } useconds_t ualarm( @@ -84,9 +90,22 @@ useconds_t ualarm( } } - tp.tv_sec = useconds / TOD_MICROSECONDS_PER_SECOND; - tp.tv_nsec = (useconds % TOD_MICROSECONDS_PER_SECOND) * 1000; - _Watchdog_Insert_ticks( the_timer, _Timespec_To_ticks( &tp ) ); + /* + * If useconds is non-zero, then the caller wants to schedule + * the alarm repeatedly at that interval. If the interval is + * less than a single clock tick, then fudge it to a clock tick. + */ + if ( useconds ) { + Watchdog_Interval ticks; + + tp.tv_sec = useconds / TOD_MICROSECONDS_PER_SECOND; + tp.tv_nsec = (useconds % TOD_MICROSECONDS_PER_SECOND) * 1000; + ticks = _Timespec_To_ticks( &tp ); + + if ( ticks == 0 ) + ticks = 1; + _Watchdog_Insert_ticks( the_timer, _Timespec_To_ticks( &tp ) ); + } return remaining; } |