diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2003-08-14 13:08:58 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2003-08-14 13:08:58 +0000 |
commit | b56c1a3ab7c3215b5ca7d3e2a2a5473c35e16529 (patch) | |
tree | d0a4873c62a6e1bc417eb2e671d53543a4d81262 /cpukit/posix/src/alarm.c | |
parent | 2003-08-14 Ralf Corsepius <corsepiu@faw.uni-ulm.de> (diff) | |
download | rtems-b56c1a3ab7c3215b5ca7d3e2a2a5473c35e16529.tar.bz2 |
2003-08-14 Joel Sherrill <joel@OARcorp.com>
PR 92/rtems
* Makefile.am, src/alarm.c, src/psignal.c: Added ualarm() and usleep().
* src/ualarm.c, src/usleep.c: New files.
Diffstat (limited to 'cpukit/posix/src/alarm.c')
-rw-r--r-- | cpukit/posix/src/alarm.c | 59 |
1 files changed, 43 insertions, 16 deletions
diff --git a/cpukit/posix/src/alarm.c b/cpukit/posix/src/alarm.c index 13c4c40202..dacd06adf0 100644 --- a/cpukit/posix/src/alarm.c +++ b/cpukit/posix/src/alarm.c @@ -22,6 +22,24 @@ #include <rtems/posix/pthread.h> #include <rtems/posix/psignal.h> +Watchdog_Control _POSIX_signals_Alarm_timer; + +/*PAGE + * + * _POSIX_signals_Alarm_TSR + */ + +void _POSIX_signals_Alarm_TSR( + Objects_Id id, + void *argument +) +{ + int status; + + status = kill( getpid(), SIGALRM ); + /* XXX can't print from an ISR, should this be fatal? */ +} + unsigned int alarm( unsigned int seconds ) @@ -31,22 +49,31 @@ unsigned int alarm( the_timer = &_POSIX_signals_Alarm_timer; - switch ( _Watchdog_Remove( the_timer ) ) { - case WATCHDOG_INACTIVE: - case WATCHDOG_BEING_INSERTED: - break; - - case WATCHDOG_ACTIVE: - case WATCHDOG_REMOVE_IT: - /* - * The stop_time and start_time fields are snapshots of ticks since - * boot. Since alarm() is dealing in seconds, we must account for - * this. - */ - - remaining = the_timer->initial - - ((the_timer->stop_time - the_timer->start_time) / _TOD_Ticks_per_second); - break; + /* + * Initialize the timer used to implement alarm(). + */ + + if ( !the_timer->routine ) { + _Watchdog_Initialize( the_timer, _POSIX_signals_Alarm_TSR, 0, NULL ); + } else { + switch ( _Watchdog_Remove( the_timer ) ) { + case WATCHDOG_INACTIVE: + case WATCHDOG_BEING_INSERTED: + break; + + case WATCHDOG_ACTIVE: + case WATCHDOG_REMOVE_IT: + /* + * The stop_time and start_time fields are snapshots of ticks since + * boot. Since alarm() is dealing in seconds, we must account for + * this. + */ + + remaining = the_timer->initial - + ((the_timer->stop_time - the_timer->start_time) / + _TOD_Ticks_per_second); + break; + } } _Watchdog_Insert_seconds( the_timer, seconds ); |