Timer Server and Blocking Calls

Sebastian Huber sebastian.huber at embedded-brains.de
Thu Nov 19 14:19:46 UTC 2009


I reworked the timer server implementation.

The previous timer server implementation had some drawbacks.  Firstly it did
not work because the thread delay ended function (_Thread_Delay_ended) removes
all blocking states which could result in an unrelated unblock with fatal
consequences (destroyed ready chains and arbitrary code execution).  Secondly
it was the duty of the timer server thread to process insertions of new timers
and manipulations of running timers.  So a context switch was necessary for
each timer operation.  This can be a major performance problem in case you use
a timer for timeout monitoring.

With the new implementation you are able to block on any resource or time
within a timer service routine.  No context switches are necessary to
manipulate timers of the timer server.  The data used by the timer server is
structured in an timer server control block (_Timer_server_Control).  So it is
easy to create more instances of timer servers to use different priorities and
modes for different domains of timer service users (currently no API exists for

The classic timer server API did not change through the new implementation.

It is difficult to get the implementation right since the timer may be
manipulated from interrupt service routines, threads and routines invoked by
the timer server itself.  It is not possible to use mutexes because ISRs cannot
block.  Please have a look at the attached patch.


Sebastian Huber, embedded brains GmbH

Address : Obere Lagerstr. 30, D-82178 Puchheim, Germany
Phone   : +49 89 18 90 80 79-6
Fax     : +49 89 18 90 80 79-9
E-Mail  : sebastian.huber at embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ts.patch
Type: text/x-patch
Size: 34127 bytes
Desc: not available
URL: <http://lists.rtems.org/pipermail/users/attachments/20091119/770ea9a0/attachment-0001.bin>

More information about the users mailing list