From: Jan Kiszka <jan.kiszka@domain.hid>
To: Philippe Gerum <rpm@xenomai.org>
Cc: xenomai-core <xenomai@xenomai.org>
Subject: [Xenomai-core] [PATCH] native: Properly update lockcnt on recursive call from secondary mode
Date: Thu, 05 Nov 2009 18:28:10 +0100 [thread overview]
Message-ID: <4AF30B2A.3050205@domain.hid> (raw)
We cannot assume that only non-recursive rt_mutex_acquire calls will
happen; the application may be buggy and come from secondary mode. Make
sure to update the user space recursion counter correctly in any case so
that at least the mutex is kept in a valid state.
Signed-off-by: Jan Kiszka <jan.kiszka@domain.hid>
---
Can be pulled from 'for-upstream' as well.
src/skins/native/mutex.c | 14 ++++++++++++++
1 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/src/skins/native/mutex.c b/src/skins/native/mutex.c
index 29843c7..98844ef 100644
--- a/src/skins/native/mutex.c
+++ b/src/skins/native/mutex.c
@@ -96,6 +96,20 @@ static int rt_mutex_acquire_inner(RT_MUTEX *mutex, RTIME timeout, xntmode_t mode
if (timeout == TM_NONBLOCK && mode == XN_RELATIVE)
return -EWOULDBLOCK;
+ } else if (xnsynch_fast_owner_check(mutex->fastlock, cur) == 0) {
+ /*
+ * The application is buggy as it jumped to secondary mode
+ * while holding the mutex. Nevertheless, we have to keep the
+ * mutex state consistent.
+ *
+ * We make no efforts to migrate or warn here. There is
+ * CONFIG_XENO_OPT_DEBUG_SYNCH_RELAX to catch such bugs.
+ */
+ if (mutex->lockcnt == UINT_MAX)
+ return -EAGAIN;
+
+ mutex->lockcnt++;
+ return 0;
}
#endif /* CONFIG_XENO_FASTSYNCH */
--
1.6.0.2
reply other threads:[~2009-11-05 17:28 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=4AF30B2A.3050205@domain.hid \
--to=jan.kiszka@domain.hid \
--cc=rpm@xenomai.org \
--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.