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 /cpukit/posix/src/ualarm.c | |
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.
Diffstat (limited to 'cpukit/posix/src/ualarm.c')
-rw-r--r-- | cpukit/posix/src/ualarm.c | 33 |
1 files changed, 26 insertions, 7 deletions
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; } |