Timer Server and Blocking Calls

Till Straumann strauman at slac.stanford.edu
Tue Nov 10 17:36:26 UTC 2009


RTM:

> The Timer Server task is responsible for executing the timer service 
> routines associated with all task-based timers. This task executes at 
> a priority higher than any RTEMS application task, and is created 
> non-preemptible, and thus can be viewed logically as the lowest 
> priority interrupt.
>
> By providing a mechanism where timer service routines execute in task 
> rather than interrupt space, the application is allowed a bit more 
> flexibility in what operations a timer service routine can perform. 
> For example, the Timer Server can be configured to have a floating 
> point context in which case it would be safe to perform floating point 
> operations from a task-based timer. Most of the time, executing 
> floating point instructions from an interrupt service routine is not 
> considered safe.
>
VVVVVVVVVVVVVVVVVVVVVVVVV
>
> However, since the Timer Server task is non-preemptible, only 
> directives allowed from an ISR can be called in the timer service routine.
>
^^^^^^^^^^^^^^^^^^^^^^^^
>
> The Timer Server is designed to remain blocked until a task-based 
> timer fires. This reduces the execution overhead of the Timer Server.
>
I'd say it is a programming error for a user callback to block the timer 
server.

That said - it would be a good idea to detect such a situation, alert 
the user
and panic.

-- Till

Sebastian Huber wrote:
> Hi,
>
> is it allowed that a function executed within the timer server context blocks
> while acquiring a resource?
>
> If it is allowed then the timer server has a bug.  The clock tick readies the
> timer server via a _Thread_Unblock() which does not take into account that the
> timer server may block due to something other than a delay.  This may fix it:
>
> Index: cpukit/score/src/threaddelayended.c
> ===================================================================
> RCS file: /usr1/CVS/rtems/cpukit/score/src/threaddelayended.c,v
> retrieving revision 1.6
> diff -u -r1.6 threaddelayended.c
> --- cpukit/score/src/threaddelayended.c 31 Dec 2008 03:36:04 -0000      1.6
> +++ cpukit/score/src/threaddelayended.c 10 Nov 2009 12:06:49 -0000
> @@ -59,7 +59,7 @@
>  #endif
>        break;
>      case OBJECTS_LOCAL:
> -      _Thread_Unblock( the_thread );
> +      _Thread_Clear_state( the_thread, STATES_DELAYING );
>        _Thread_Unnest_dispatch();
>        break;
>    }
>
> I do not know how this affects rtems_task_wake_when() and the
> STATES_WAITING_FOR_TIME state.  What is the difference between
> STATES_WAITING_FOR_TIME and STATES_DELAYING?
>
> Have a nice day!
>
>   




More information about the users mailing list