From: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
To: roderik.wildenburg@domain.hid
Cc: xenomai@xenomai.org
Subject: Re: [Xenomai-help] sem_wait increments fault counter
Date: Thu, 07 May 2009 16:05:31 +0200 [thread overview]
Message-ID: <4A02EAAB.9040600@domain.hid> (raw)
In-Reply-To: <5D63919D95F87E4D9D34FF7748CE2C2A019C345B@ARVMAIL1.mra.roland-man.biz>
roderik.wildenburg@domain.hid wrote:
>>> every time I call sem_wait a fault counter is incremented (TRAP
>>> 0). sem_wait itself does not return an error :
>>>
>>> uc101 # cat /proc/xenomai/faults TRAP CPU0 0:
>>> 1 (Data or instruction access)
>>>
>>> what could be the reason for this? Is this serious? I have to add
>>> that sem_wait is called form a Linux-Prozess
>> (linked with
>>> xenomai libraries, but no xenomai thread is created) when
>> this happens.
>>
>> Your not enough specific to get an answer. Are you talking about
>> Linux' sem_wait or about Xenomai's sem_wait ? What Xenomai library
>> are you talking about, Xenomai native skin library or Xenomai posix
>> skin library?
>
> It´s posix skin library, we are talking about.
>
>> If using the Xenomai posix skin library (which would mean that you
>> use in fact Xenomai's sem_wait), the main thread is actually a
>> xenomai thread,
>
> That´s fine/o.k. (but I didn´t know it).
>
>> and in order to actually not create a xenomai thread, you would
>> have to call __real_pthread_create instead of pthread_create.
>> Otherwise, all threads are Xenomai threads.
>
> I try to give some more information: In fact it is a library we are
> talking about (let´s call it shmlib). This library creates a shared
> memory and a (named) semaphore which should synchronise the access to
> the shared memory. This library (shmlib) is linked with Xenomai
> posix-library, so all posix-calls within shmlib should be handled by
> Xenomai.
Well, not quite. Linking is not enough. To actually use Xenomai posix
library calls, you have to pass the bunch of -Wl,--wrap options to gcc,
which you get when calling xeno-config --posix-ldflags. Is it what you
are doing.
This shmlib is linked to different applications (build by
> different developers). To "real" Xenomai-applications with threads
> created with pthread_create and to Linux-applications which do not
> use pthread_create (but whose main thread is a Xenomai thread, if
> linked with shmlib, as I learned just now). When such a
> Linux-application calls the shmlib synchronisation function, which in
> turn calls sem_wait(), the trap 0 counter is incremented, but no
> other error or problem occurs. If I comment out the sem_wait call in
> shmlib, the counter isn´t incremented. So my conclusion was, that
> sem_wait causes the trap 0.
If the thread using the semaphore was not a Xenomai posix skin thread,
you would not be able to call Xenomai's sem_wait, it would return -1
with errno set to EPERM.
My question may seem a little bit stupid, but are you checking the
return value of sem_wait ?
>
> Is trap 0 explicitly generated by Xenomay in some error case or is it
> "just" a CPU error when executing an illegal instruction (but where
> should this illegal instruction/code come from ?) ?
>
> By the way: this error also happens with Xenoami 2.4.6.
No, Xenomai has no particular reason to voluntarily generate a trap. And
this trap probably causes the calling thread to switch to secondary
mode, so this is bad news if it is a thread with actual real-time
activities. As Philippe told you, this trap may be due to some Power PC
specific behaviour.
Also, I told you that several times already, but I will tell it once
more: the Xenomai posix skin shared memory services are only useful if
you intend to share memory between a user-space real-time application
and a kernel-space real-time module. If what you want to do is simply
share memory between user-space applications, you can use Linux' shared
memory services.
--
Gilles.
next prev parent reply other threads:[~2009-05-07 14:05 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-05 13:44 [Xenomai-help] sem_wait increments fault counter roderik.wildenburg
2009-05-07 13:02 ` Gilles Chanteperdrix
2009-05-07 13:47 ` roderik.wildenburg
2009-05-07 14:05 ` Gilles Chanteperdrix [this message]
2009-05-08 7:14 ` roderik.wildenburg
2009-05-08 10:36 ` Philippe Gerum
2009-05-08 12:11 ` roderik.wildenburg
2009-05-08 15:24 ` Gilles Chanteperdrix
2009-05-15 9:53 ` [Xenomai-help] sem_wait increments fault counter - solved roderik.wildenburg
2009-05-07 13:32 ` [Xenomai-help] sem_wait increments fault counter 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=4A02EAAB.9040600@domain.hid \
--to=gilles.chanteperdrix@xenomai.org \
--cc=roderik.wildenburg@domain.hid \
--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.