<font size=2 face="sans-serif">Hi,</font>
<p><font size=2 face="sans-serif">I have an embedded board with PowerPC
5200 running Realtime Linux with version 2.6.33 (OSADL).</font>
<p><font size=2 face="sans-serif">My application is using one high resolution
timer in Linux for alarms. This timer sometimes didn’t expire. The problem
happens very rarely, it may go many months between each time it happens
on a systems.</font>
<p><font size=2 face="sans-serif">The timer is set by function timer_settime
with absolute time.</font>
<p><font size=2 face="sans-serif">I have done some interesting observations
when the timer didn’t expire: <br>
- Function timer_gettime returns remaining time 1ns.<br>
- Active timers are checked by displaying file /proc/timer_list and the
timer_list didn’t show this timer in the active timer list. </font>
<p><font size=2 face="sans-serif">I have looked into the Linux source and
found a possible scenario:</font>
<p><font size=2 face="sans-serif">The function timer_gettime ends up in
function common_timer_get (posix-timers.c). &nbsp;Function common_timer_get
returns it_value.tv_nsec = 1 if timer is active and remaining time is &lt;=
0. This means that the timer has counted down and the timer state must
be 'enqueued' or 'callback'.</font>
<p><font size=2 face="sans-serif">I suppose that it is in state 'callback',
that means it is running in function __run_hrtimer (hrtimer.c). Function
__run_hrtimer is calling function__remove_hrtimer that remove the timer
from timer active list before it changes timer state from 'enqueued' to
'callback'.</font>
<p><font size=2 face="sans-serif">Several functions are called in function
__run_hrtimer between changing timer state to 'callback' and the end of
the function where the state 'callback' is cleared. &nbsp;If it is hanging
here, the function timer_gettime may return 1ns while the timer is not
in the active list. Here it is calling several functions in Linux kernel
and the callback function in the application. </font>
<p><font size=2 face="sans-serif">I have checked the callback function
in my application. It is signaling a semaphore and setting the timer again
on the same thread. I can't see why that should not work. </font>
<p><font size=2 face="sans-serif">Is there someone that has seen a similar
case?</font>
<p><font size=2 face="sans-serif">Is there someone that has an idea of
what are going wrong here?</font>