From b56c1a3ab7c3215b5ca7d3e2a2a5473c35e16529 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Thu, 14 Aug 2003 13:08:58 +0000 Subject: 2003-08-14 Joel Sherrill PR 92/rtems * Makefile.am, src/alarm.c, src/psignal.c: Added ualarm() and usleep(). * src/ualarm.c, src/usleep.c: New files. --- cpukit/posix/src/alarm.c | 59 +++++++++++++++++++++++++++++++++++------------- 1 file changed, 43 insertions(+), 16 deletions(-) (limited to 'cpukit/posix/src/alarm.c') 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 #include +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 ); -- cgit v1.2.3