All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luotao Fu <devtty0@domain.hid>
To: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
Cc: xenomai@xenomai.org
Subject: Re: [Xenomai-help] Strangeness in named Semaphores(xenomai posix skin)
Date: Sat, 22 Oct 2005 00:11:51 +0200	[thread overview]
Message-ID: <435967A7.6060903@domain.hid> (raw)
In-Reply-To: <17241.24548.920222.440189@domain.hid>

Gilles Chanteperdrix wrote:
> Luotao Fu wrote:
>  > Hi folks,
>  > 
>  > I got the feeling, that named semaphores in xenomai posix skin don't
>  > work properly. I hacked some simple code to test this and attached the
>  > code to this mail, so that you might have a look of my problem yourself.
> 
> There was one issue on POSIX skin side: the sem_timedwait function
> was not implemented in Xenomai user-space POSIX library, your code was
> hence calling libc sem_timedwait, which accounted for the segfault. The
> remaining misbehaviours you observed are due to problems in the example
> code.

Thanx Gilles, I've just sent out another mail to this thread before I
noticed your mail. Well sorry for the delay than. I found the
sem_timedwait in posix_overrides.h
 #define sem_timedwait pse51_sem_timedwait
so I thought it'll be handled by the posix skin.

> 
>  > (...)
>  > 
>  > char *semName = "/testSem";
>  > struct timespec t;
>  > 
>  > void *funcA(void *parm){
>  > 	sem_t *binSem;
>  >  	if ((binSem = sem_open(semName, O_CREAT)) == SEM_FAILED){
> 
> When calling sem_open with the O_CREAT flag, you have to pass a "mode"
> and most importantly a "value" argument which is the initial value of
> the semaphore. Your also make the assumption that 0 is a valid numeric
> value for the enum O_RDONLY/O_WRONLY/O_RDWR.
>

oh, hell yeah, forgot it.

> 
.......
>  > 	sem_post(binSem);
>  >  	sem_wait(binSem); 	
> 
> Pending on a semaphore is forbidden for non-Xenomai threads, so sem_wait
> returns -1 with errno set to EPERM here and the semaphore remains
> available, assuming, of course that the call to sem_open was changed to
> initialize the semaphore value to 0.
>

Well this is interesting. I did have had to test the Return value here.

I'd change the testcode as your advice and give it some more tests.

Thanx
cheers
Luotao Fu


  reply	other threads:[~2005-10-21 22:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-21 15:57 [Xenomai-help] Strangeness in named Semaphores(xenomai posix skin) Luotao Fu
2005-10-21 19:39 ` Gilles Chanteperdrix
2005-10-21 21:54   ` Luotao Fu
2005-10-21 21:38 ` Gilles Chanteperdrix
2005-10-21 22:11   ` Luotao Fu [this message]
2005-10-22  7:27     ` Gilles Chanteperdrix

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=435967A7.6060903@domain.hid \
    --to=devtty0@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.