From: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
To: Roland Stigge <stigge@antcom.de>
Cc: 677633@bugs.debian.org, Xenomai@xenomai.org
Subject: Re: [Xenomai] Debian bug report #677633: Xenomai posix skin : bug with nanosleep function
Date: Fri, 15 Jun 2012 23:11:41 +0200 [thread overview]
Message-ID: <4FDBA50D.6060605@xenomai.org> (raw)
In-Reply-To: <4FDB96AE.4090008@antcom.de>
On 06/15/2012 10:10 PM, Roland Stigge wrote:
>
> Hi,
>
> The nanosleep_test.c code shows a malfunction of the nanosleep function
> when a timer periodically triggering a signal.
> When nanosleep is interrupted the variable holding the rest of the time
> to sleep is immediately zero.
>
>
>
> However, no bug is reported without the xenomai's posix skin.
The following patch should fix the bug:
diff --git a/ksrc/skins/posix/clock.c b/ksrc/skins/posix/clock.c
index 024260d..107ebb0 100644
--- a/ksrc/skins/posix/clock.c
+++ b/ksrc/skins/posix/clock.c
@@ -336,15 +336,12 @@ int clock_nanosleep(clockid_t clock_id,
if (xnthread_test_info(cur, XNBREAK)) {
if (flags == 0 && rmtp) {
- xnticks_t now, expiry;
xnsticks_t rem;
- now = clock_get_ticks(clock_id);
- expiry = xntimer_get_date(&cur->rtimer);
+ rem = xntimer_get_timeout_stopped(&cur->rtimer);
xnlock_put_irqrestore(&nklock, s);
- rem = expiry - now;
- ticks2ts(rmtp, rem > 0 ? rem : 0);
+ ticks2ts(rmtp, rem > 1 ? rem : 0);
} else
xnlock_put_irqrestore(&nklock, s);
Note however that with xenomai, a signal received during nanosleep will
trigger a switch to secondary mode. So, this usage is only possible for
a real-time thread in exceptional conditions (to handle an error for
instance), not when latency matters.
--
Gilles.
prev parent reply other threads:[~2012-06-15 21:11 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-15 20:10 [Xenomai] Debian bug report #677633: Xenomai posix skin : bug with nanosleep function Roland Stigge
2012-06-15 20:34 ` Gilles Chanteperdrix
2012-06-15 21:11 ` Gilles Chanteperdrix [this message]
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=4FDBA50D.6060605@xenomai.org \
--to=gilles.chanteperdrix@xenomai.org \
--cc=677633@bugs.debian.org \
--cc=Xenomai@xenomai.org \
--cc=stigge@antcom.de \
/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.