I have a built-in board with PowerPC 5200 running Realtime Linux with version 2.6.33 (OSADL). My application uses a single high resolution timer in Linux for alarms. This timer sometimes did not expire. The problem is very rare, it can take many months between each time it happens in systems.
The timer is set by the timer_settime function with absolute time. I made some interesting observations when the timer did not expire:
- The timer_gettime function returns the remaining time 1ns.
- Active timers are checked by displaying the / proc / timer _list file, and the timer list did not show this timer in the active timer list.
I studied the source of Linux and found a possible scenario:
The timer_gettime function ends with the common_timer_get (posix-timers.c) function. The common_timer_get function returns it_value.tv_nsec = 1 if the timer is active and the remaining time is <= 0. This means that the timer counts down and the timer status should be “in line” or “callback”.
I assume that it is in a "callback" state, that is, it works in the __run_hrtimer (hrtimer.c) function. The __run_hrtimer function calls the __remove_hrtimer function, which removes the timer from the active timer list before it changes the state of the timer from "enqueued" to "callback".
The __run_hrtimer function calls several functions between changing the timer state to a callback and ending the function in which the callback state is cleared. If it hangs here, the timer_gettime function can return 1ns while the timer is not in the active list. Here, it calls several functions in the Linux kernel and a callback function in the application.
I checked the callback function in my application. It signals a semaphore and sets a timer in the same thread again. I do not understand why this should not work.
Does anyone have seen a similar case?
Does anyone have an idea of what's going wrong here?
linux linux-kernel embedded-linux
Vijay katoch
source share