All of lore.kernel.org
 help / color / mirror / Atom feed
From: Philippe Gerum <rpm@xenomai.org>
To: Hannes Mayer <h.mayer@domain.hid>
Cc: adeos-main@gna.org
Subject: Re: [Adeos-main] do_gettimeofday in ADEOS ISR
Date: Wed, 03 Aug 2005 10:03:01 +0200	[thread overview]
Message-ID: <42F07A35.7070001@domain.hid> (raw)
In-Reply-To: <42EFF665.3060000@domain.hid>

Hannes Mayer wrote:
> Hi all!
> 
> I was just wondering if calling do_gettimeofday in an ADEOS interrupt
> handler might cause any problems whatsoever ?
> 
> My ISR:
> flags = adeos_critical_enter (NULL);
> [...]
> do_gettimeofday()
> [...]
> adeos_critical_exit (flags);
> 
> I saw that the code for do_gettimeofday is different in kernel 2.4 and
> kernel 2.6:
> 
> Kernel 2.4:
> void do_gettimeofday(struct timeval *tv) {
> [...]
> read_lock_irqsave(&xtime_lock, flags);
> [...]
> read_unlock_irqrestore(&xtime_lock, flags);
> 
> Kernel 2.6:
> void do_gettimeofday(struct timeval *tv) {
> [...]
> do {
> [...]
> seq = read_seqbegin(&xtime_lock);
> [...]
> } while (read_seqretry(&xtime_lock, seq));
> 
> Well, read_lock_irqsave in 2.4 looks like a possible source for trouble,
> while read_seqbegin in 2.6 doesn't do anything with interrupts, right ?
> 

Yes, but that's not better anyway. Imagine what would happen if an 
undergoing write sequence on the xtime_lock in the Linux domain was 
preempted by an ISR from a higher priority domain which in turn calls 
do_gettimeofday(): the read sequence running over your high priority ISR 
would then loop on read_seqretry(), waiting for the undergoing write to 
end. Problem is, that the undergoing write sequence would not be allowed 
to resume until your current high priority domain running 
do_gettimeofday() relinquishes the processor. Catch 22. This could 
happen in both UP and SMP configs, not to speak of the funky behaviour 
one would get with the additional spinlock recursion issue over SMP, 
since a write sequence also grabs a spinlock.

-- 

Philippe.


  reply	other threads:[~2005-08-03  8:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-02 22:40 [Adeos-main] do_gettimeofday in ADEOS ISR Hannes Mayer
2005-08-03  8:03 ` Philippe Gerum [this message]
2005-08-17 20:22   ` Hannes Mayer
2005-08-22 14:08     ` Philippe Gerum
2005-08-22 14:16       ` Philippe Gerum

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=42F07A35.7070001@domain.hid \
    --to=rpm@xenomai.org \
    --cc=adeos-main@gna.org \
    --cc=h.mayer@domain.hid \
    /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.