Bugs POSIX API Timer

Joel Sherrill joel.sherrill at OARcorp.com
Sun Aug 11 22:59:58 UTC 2013


Sorry for the delay. I was on travel and not in a good position
for deep thought.

On 8/5/2013 2:38 PM, Nico Forlano wrote:
> Hi,
>
> I think I found two bugs / unexpected behaviour in the POSIX timer
> implementation
>
> 1.) Emitted signal on timer expiration is only relayed to the thread which
> created the timer instead of the process / all threads.
I think you are correct and we are wrong. When implementing this, I
personally leaned to making some items more thread specific. In some
cases, you had to and in this one, I may have gone too far.
> 2.) When you initialize a timer with an interval of zero, the timer is
> supposed to expire only once and then stop. You would expect that the
> value remains at zero in this case, however in RTEMS the timer resets to
> an arbitrary (?) value and starts counting down again.
Looking at posix/src/timertsr.c, the method _POSIX_Timer_Insert_helper()
is only invoked if it is non-zero.

I am suspicious the error is in timergettime.c which is not looking
>
> I attached two examples that demonstrate both cases. If you compile them
> on Linux, they behave as I would expect from the POSIX documentation.
Can you attach these to a PR so we can track this?

I certainly need to run them.
> Regarding 1.):
> Sebastian Huber pointed out to me that  _POSIX_Timer_TSR() emits the
> signal with an explicit call to pthread_kill(). From the POSIX
> documentation I would have expected a signal to all threads of the process
> using kill().
Did you find an explicit statement for a call to kill() or just that this is
all documented as part "per-process timers"?

I just want to make sure I am reading the same sections you are.
> If this is changed I believe the psxtimer01 test from the POSIX part of
> the testsuit has to be updated as well. There are three threads which all
> create their own timer and all wait for a signal with the same signal
> number. If the threads are not addressed directly with pthread_kill()
> anymore I assume the highest priority thread will just grab the signals of
> all timers, which does not seem to be the intention.
Off the top of my head, we should be able to mask the signals
at the process level and only enable them individually for the threads.
Still a change.
> If the usage of pthread_kill() is intended, is there any way to set the ID
> of the target thread?
Not within POSIX but that's an interesting idea.

If you aren't bound to POSIX, the Classic API Timers are much more
flexible.
> Regards
> Nico
>
>


-- 
Joel Sherrill, Ph.D.             Director of Research & Development
joel.sherrill at OARcorp.com        On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
Support Available                (256) 722-9985




More information about the users mailing list