All of lore.kernel.org
 help / color / mirror / Atom feed
From: Philippe Gerum <rpm@xenomai.org>
To: Niklaus Giger <niklaus.giger@domain.hid>
Cc: xenomai-core <xenomai@xenomai.org>
Subject: Re: [Xenomai-core] Deviation in Xenomai-Solo from vxWorks behaviour
Date: Mon, 15 Sep 2008 11:18:53 +0200	[thread overview]
Message-ID: <48CE287D.9080800@domain.hid> (raw)
In-Reply-To: <200809141519.01180.niklaus.giger@domain.hid>

Niklaus Giger wrote:
> Hi
> 
> The attached program works fine under vxWorks 6.6 (powerpc).
> Running it under the current xenomai-solo (trunk) on my GNU/Debian
> x86 system it gets stuck at line 82:
> 
> Here is the output from vxWorks
>> timex tSysMain
>> assert passed at tSysMain line 66
>> assert passed at tSysMain line 67
>> assert passed at tSysMain line 70
>> assert passed at tSysMain line 71
>> assert passed at tSysMain line 74
>> assert passed at tSysMain line 75
>> assert passed at tSysMain line 77
>> assert passed at tSysMain line 78
>> assert passed at tSysMain line 79
>> assert passed at tSysMain line 80
>> assert passed at tSysMain line 82
>> assert passed at tSysMain line 83
>> tSysMain done
>> timex: time of execution = 600 +/- 2 (0%) millisecs
> whereas my gdb reports the following
>> Starting program:
>> /home/hcu/celsius/project/metaFrame/bin/BSys/mak/xeno_vx-solo/debug/tst
>> [Thread debugging using libthread_db enabled]
>> [New Thread 0xb7c056c0 (LWP 32206)]
>> [New Thread 0xb7f02b90 (LWP 32210)]
>> [New Thread 0xb7ef1b90 (LWP 32213)]
>> assert passed at testTask line 66
>> assert passed at testTask line 67
>> assert passed at testTask line 70
>> assert passed at testTask line 71
>> assert passed at testTask line 74
>> assert passed at testTask line 75
>> assert passed at testTask line 77
>> assert passed at testTask line 78
>> assert passed at testTask line 79
>> assert passed at testTask line 80
>> ^C
>> Program received signal SIGINT, Interrupt.
>> [Switching to Thread 0xb7c056c0 (LWP 32206)]
>> 0xb7f05424 in __kernel_vsyscall ()
>> (gdb) t 3
>> [Switching to thread 3 (Thread 0xb7ef1b90 (LWP 32213))]#0  0xb7f05424 in
>> __kernel_vsyscall () (gdb) i s
>> #0  0xb7f05424 in __kernel_vsyscall ()
>> #1  0xb7e9b025 in pthread_cond_wait@domain.hid () from
>> /lib/i686/cmov/libpthread.so.0 #2  0xb7eaff2f in syncobj_pend
>> (sobj=0x83fd0d0, timeout=0x0, syns=0xb7ef12a4) at syncobj.c:152 #3 
>> 0xb7ebff80 in xsem_take (sem=0x83fd0c8, timeout=-1) at semLib.c:83 #4 
>> 0xb7ec0837 in semTake (sem_id=138399944, timeout=-1) at semLib.c:404 #5 
>> 0x08048a8d in testTask (a1=0, a2=0, a3=0, a4=0, a5=0, a6=0, a7=0, a8=0,
>> a9=0, a10=0) at ../../BSys/src/tst_main.cpp:82 #6  0xb7ec116b in
>> task_trampoline (arg=0x83fcee8) at taskLib.c:255 #7  0xb7e974c0 in
>> start_thread () from /lib/i686/cmov/libpthread.so.0 #8  0xb7ceb55e in clone
>> () from /lib/i686/cmov/libc.so.6
> It looks like under xenomai a failing semTake(aSemaphore, nWaitTime))
> erroneously decrements the counter instead of leaving .
>

You were 100% right. The patch below fixes up the sema4 count as required, thanks.

diff --git a/vxworks/semLib.c b/vxworks/semLib.c
index 3588160..62f9326 100644
--- a/vxworks/semLib.c
+++ b/vxworks/semLib.c
@@ -81,12 +81,15 @@ static STATUS xsem_take(struct wind_sem *sem, int timeout)
 		timespec = NULL;

 	ret = syncobj_pend(&sem->u.xsem.sobj, timespec, &syns);
-	if (ret == -ETIMEDOUT)
-		ret = S_objLib_OBJ_TIMEOUT;
-	else if (ret == -EINTR)
-		ret = OK;	/* Flushed. */
-	else if (ret == -EIDRM)
+	if (ret == -EIDRM)
 		return S_objLib_OBJ_DELETED;
+	if (ret) {
+		sem->u.xsem.value++;
+		if (ret == -ETIMEDOUT)
+			ret = S_objLib_OBJ_TIMEOUT;
+		else if (ret == -EINTR)
+			ret = OK;	/* Flushed. */
+	}
 done:
 	syncobj_unlock(&sem->u.xsem.sobj, &syns);

-- 
Philippe.



      parent reply	other threads:[~2008-09-15  9:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-14 13:18 [Xenomai-core] Deviation in Xenomai-Solo from vxWorks behaviour Niklaus Giger
2008-09-14 17:53 ` Philippe Gerum
2008-09-14 18:11   ` Niklaus Giger
2008-09-15  8:51   ` Philippe Gerum
2008-09-15  9:18 ` Philippe Gerum [this message]

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=48CE287D.9080800@domain.hid \
    --to=rpm@xenomai.org \
    --cc=niklaus.giger@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.