All of lore.kernel.org
 help / color / mirror / Atom feed
From: Philippe Gerum <rpm@xenomai.org>
To: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
Cc: xenomai@xenomai.org, Andreas Glatz <AndreasGlatz@domain.hid>
Subject: Re: [Xenomai-help] Running out of stack memory in kernel-space
Date: Tue, 23 Jun 2009 12:23:37 +0200	[thread overview]
Message-ID: <1245752617.3986.166.camel@domain.hid> (raw)
In-Reply-To: <4A40A273.1050505@domain.hid>

On Tue, 2009-06-23 at 11:37 +0200, Gilles Chanteperdrix wrote:
> Philippe Gerum wrote:
> > On Mon, 2009-06-22 at 09:23 -0400, Andreas Glatz wrote:
> >> 1) In the legacy code I am porting, critical sections are
> >> protected by disabling/enabling ALL interrupts (like
> >> sti/cli in kernel-space). This method is much faster than
> >> locking a mutex, which might put a task to sleep.
> > 
> > Usually yes, but at the expense of wrecking the priority-based model of
> > the RTOS when misused.
> > 
> >>  Are there
> >> similar, portable functions available under Xenomai or IPIPE?
> > 
> > You should never rely directly on I-pipe features, using a Xenomai
> > interface is the way to go.
> > 
> > If writing driver code based on RTDM (the recommended way), see there:
> > http://www.xenomai.org/documentation/branches/v2.4.x/html/api/group__rtdmsync.html
> > 
> > Otherwise, if you are writing ad hoc application code in kernel space,
> > which is asking for trouble (yeah, I can't help it, sorry), you will
> > have to resort to core services from the Xenomai nucleus directly: see
> > splhigh(), splexit(), xnlock_get[irqsave], xnlock_put[_irqrestore].
> > Regarding the second form, you may notice a pre-defined lock called
> > "nklock", which is used by the nucleus internally. You may use it at
> > your own risk (basically introducing more latency if misused), but you
> > may also define your own RT spinlock based on the xnlock_t type, taking
> > care of possible locking order issues with the nklock.
> > see include/asm-generic/system.h.
> 
> The rule of thumb is: if you need to reschedule while holding an xnlock,
> then this xnlock must be the nklock. Otherwise, you will be in trouble.

Actually, the real rule of thumb is: do not call into any Xenomai
services holding this lock, unless you really know what you are doing.

> 
-- 
Philippe.




  reply	other threads:[~2009-06-23 10:23 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-28 15:59 [Xenomai-help] Running out of stack memory in kernel-space Andreas Glatz
2009-05-28 16:39 ` Philippe Gerum
2009-05-28 18:23   ` Andreas Glatz
2009-05-28 22:14     ` Philippe Gerum
2009-05-28 16:52 ` Philippe Gerum
2009-05-28 17:58   ` Andreas Glatz
2009-05-28 21:47     ` Philippe Gerum
2009-06-22 13:23       ` Andreas Glatz
2009-06-23  9:30         ` Philippe Gerum
2009-06-23  9:37           ` Gilles Chanteperdrix
2009-06-23 10:23             ` Philippe Gerum [this message]
2009-06-23 10:37           ` 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=1245752617.3986.166.camel@domain.hid \
    --to=rpm@xenomai.org \
    --cc=AndreasGlatz@domain.hid \
    --cc=gilles.chanteperdrix@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.