All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
To: Chris Stone <chris.linux@domain.hid>
Cc: Xenomai Help <xenomai@xenomai.org>
Subject: Re: [Xenomai-help] Xenomai and timers.
Date: Thu, 16 Dec 2010 21:55:46 +0100	[thread overview]
Message-ID: <4D0A7CD2.4000301@domain.hid> (raw)
In-Reply-To: <BAY149-w569BBC6219044CB125C68BE4150@domain.hid>

Chris Stone wrote:
> Thanks for your reply, and I realize that I am now getting off topic
> for this list, but if the explanation is easy perhaps I could impose
> on you a little further. How does one fix the POSIX code to deal with
> this issue? When sem_timedwait() returns with ETIMEDOUT, how does one
> know that the time was changed by another task and the timeout was
> not the duration that was asked for?

The answer is that POSIX is a big mess with regard to this issue... Some
functions allow to choose between relative and absolute timeouts
(clock_nanosleep, timer_settime), others allow to change the clock
(pthread_cond_timedwait), since using CLOCK_MONOTONIC automatically
solves this issue, some use relative timeouts. Others such as
sem_timedwait, pthread_mutex_timedlock pthread_timedjoin, offer no choice.

We could add some pthread_mutexattr_setclock_np and sem_setclock_np
services, but then your code would only run with Xenomai, which makes
POSIX a little less useful.

Note that usually, a timeout is an unexpected rare event not in need for
a lot of precision, and clock_settime should not make big jumps, I do
not think using sem_timedwait to create a periodic task was the plan.
Also note that Xenomai and Linux clock are separated, so, if Linux calls
clock_settime, Xenomai timers will not see it.

-- 
                                                                Gilles.


  reply	other threads:[~2010-12-16 20:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-16 17:55 [Xenomai-help] Xenomai and timers Chris Stone
2010-12-16 18:40 ` Philippe Gerum
2010-12-16 19:30   ` Chris Stone
2010-12-16 20:55     ` Gilles Chanteperdrix [this message]
2010-12-17  9:09     ` Philippe Gerum
2010-12-17 14:35       ` Chris Stone
2010-12-20  7:59       ` Richard Cochran

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4D0A7CD2.4000301@domain.hid \
    --to=gilles.chanteperdrix@xenomai.org \
    --cc=chris.linux@domain.hid \
    --cc=xenomai@xenomai.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.