All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matthias Schneider <ma30002000@yahoo.de>
To: "xenomai@xenomai.org" <xenomai@xenomai.org>
Subject: [Xenomai] Issue in notifier_callback while threadobj_lock is being held (forge/mercury)
Date: Sat, 26 Apr 2014 09:58:31 +0100 (BST)	[thread overview]
Message-ID: <1398502711.53016.YahooMailNeo@web171601.mail.ir2.yahoo.com> (raw)

Hi all,

when threadobj_lock is being held and a thread suspension triggers a call of
notifier_callback, I am experiencing some issues. The scenario in my case
was a thread being started waiting on threadobj_wait_start()/wait_on_barrier()
while a thread suspension was already triggered. (In case the started thread is 
of lower priority than the starting thread, threadobj_start() will not wait
for it).

The problem I was experiencing (due to timing) was that threadobj_lock()
was called in notifier_callback(), failed because the mutex was already held
(by wait_on_barrier()) and thus did not set the threadobj->status variable, 
however, wait_on_barrier() had already unset the status variable before actually 
unlocking the mutex in pthread_cond_wait().

This caused threadobj_lock() in notifier_callback() return -EDEADLK and not 
doing anything, and threadobj_unlock() to assert on __threadobj_tag_unlocked(thobj)
due status not reflecting the locked state.

Additionally I see problems in notifier_callback() in general since it will
leave the threadobj unlocked on return regardless of its previos state.
I am not sure how to address this issue, I have helped myself by blocking 
SIGNOTIFY in wait_on_barrier(), but that is obviously an incomplete fix
(if it is any at all). Probably there are other situtions as well that could 
cause this behavior.

Any ideas on what to do about that? 

Thanks in advance,
Matthias


             reply	other threads:[~2014-04-26  8:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-26  8:58 Matthias Schneider [this message]
2014-04-26 10:32 ` [Xenomai] Issue in notifier_callback while threadobj_lock is being held (forge/mercury) Philippe Gerum
2014-04-26 16:13   ` Philippe Gerum
2014-05-01 11:49     ` Matthias Schneider
2014-05-01 12:52       ` Philippe Gerum
2014-05-01 13:00         ` Philippe Gerum
2014-05-01 14:28           ` Matthias Schneider

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=1398502711.53016.YahooMailNeo@web171601.mail.ir2.yahoo.com \
    --to=ma30002000@yahoo.de \
    --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.