Linux timer freezes from time to time and stops at 1ns

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?

+8
linux linux-kernel embedded-linux
source share

No one has answered this question yet.

See related questions:

4800
How to find all files containing specific text in Linux?
1773
How to symbolize a file in Linux?
1528
How to change echo output color on Linux
1324
How do I request Yes / No / Cancel input in a Linux shell script?
1101
How to copy a file folder to another folder on Unix / Linux?
866
Why does the C preprocessor interpret the word "linux" as the constant "1"?
2
How to find delayed timers in the Linux kernel
one
Creating a simple timer application
0
How to find out if a timer has ended in C
0
what does active mean for linux timer?

All Articles