All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
To: xenoka09@domain.hid
Cc: xenomai@xenomai.org
Subject: Re: [Xenomai-help] POSIX skin, simple example with mutex not working...
Date: Thu, 23 Jul 2009 17:30:58 +0200	[thread overview]
Message-ID: <4A688232.6040403@domain.hid> (raw)
In-Reply-To: <Pine.LNX.4.62.0907231644270.9450@domain.hid>

Kolja Waschk wrote:
> Hi,
> 
> As a newcomer to Xenomai, I was until now successfully experimenting
> with the native skin. Now that it comes to run an existing application
> that is written for POSIX threads, a few problems show up. The
> pthread_mutex_lock() _always_ returns 1 (EPERM) to me, although there
> are no forks involved and policy should have been to SCHED_FIFO.

Setting the policy to SCHED_FIFO is not necessary. However, your thread 
initialization has several defects:
- it does not check the return values of the function it calls, so you 
do not see the errors which follow
- setinheritsched(1) does not mean anything (and actually, it would seem 
it means the contrary of what you would like, but I can not say for 
sure), you should use the constants PTHREAD_EXPLICIT_SCHED or 
PTHREAD_INHERIT_SCHED
- setting the priority to anything else than 0 in the thread creation 
attributes only works once you have set the scheduling policy (at least 
it did a long time ago with linuxthreads, and I guess you are using 
linuxthreads).

> 
> If that's of interest, I'm developing for a Blackfin uClinux (NOMMU)
> target with newest uClinux-dist snapshot (Kernel
> 2.6.30.2-ADI-2010R1-pre, Xenomai 2.4.91, Nucleus v2.5-rc2) with FDPIC
> userland. For building,  I simply used

Yes, that is of interest, because I do not think we experience this 
issue on other platforms.

> 
>> bfin-linux-uclibc-gcc `/usr/xenomai/bin/xeno-config --posix-cflags`
>>   `/usr/xenomai/bin/xeno-config --posix-ldflags`  try.c -o try
> 
> Writing an explicit command line including the -Wl,@(wrapper) etc.
> doesn't change anything.  The output of the attached code, compiled,
> shows the return value from mutex_lock, first called from the NRT
> main(), then from a thread that IMHO should run as a realtime thread:

main is a real-time thread. All threads are real-time threads, whatever 
the scheduling policy you use. The only way to create a non real-time 
thread is to call __real_pthread_create.

So, in short, your example should work, everyone should return 0. There 
is a bug somewhere.

-- 
                                           Gilles



  reply	other threads:[~2009-07-23 15:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-23 15:17 [Xenomai-help] POSIX skin, simple example with mutex not working Kolja Waschk
2009-07-23 15:30 ` Gilles Chanteperdrix [this message]
     [not found]   ` <Pine.LNX.4.62.0907231741280.9450@domain.hid>
2009-07-23 17:55     ` Gilles Chanteperdrix
2009-07-23 19:28       ` Kolja Waschk
2009-07-23 20:27         ` Philippe Gerum
2009-07-23 21:23           ` Philippe Gerum
2009-07-24 15:25             ` Kolja Waschk

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=4A688232.6040403@domain.hid \
    --to=gilles.chanteperdrix@xenomai.org \
    --cc=xenoka09@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.