All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai-core] xenomai-solo-vxWorks: Calling semGive twice on a binary semaphore should not return an error
@ 2008-09-21 20:26 Niklaus Giger
  2008-09-22 14:49 ` Philippe Gerum
  0 siblings, 1 reply; 3+ messages in thread
From: Niklaus Giger @ 2008-09-21 20:26 UTC (permalink / raw)
  To: xenomai-core

[-- Attachment #1: Type: text/plain, Size: 472 bytes --]

Hi

Examining errors in my big testsuite I discovered that giving a second
time a binary semaphore xenomai returns an error where vxWorks reports OK.

See the attached test case.
> sudo  ../../bin/BSys/mak/xeno_vx-solo/debug/tst
> assert passed at testTask line 65
> assert passed at testTask line 66
> assert failed at testTask line 67
> testTask done
> Xenomai/SOLO: failed to remove registry mount point /mnt/xenomai/4569
> (errno=16)

Best regards

-- 
NIklaus Giger


[-- Attachment #2: tst_main.cpp --]
[-- Type: text/x-c++src, Size: 1727 bytes --]

#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>


#define assert(cond) \
  if (!cond) printf("assert failed at %s line %d\n", __FUNCTION__, __LINE__); \
  else  printf("assert passed at %s line %d\n", __FUNCTION__, __LINE__);


#if defined(__SOLO__) || defined(_WRS_VXWORKS_MAJOR)
// #include <vxWorks.h>
#include <semLib.h>
#include <taskLib.h>
#include <tickLib.h>
#include <kernelLib.h>
#include <errnoLib.h>

void testTask(long a1, long a2, long a3, long a4, long a5,
	long a6, long a7, long a8, long a9, long a10);
bool finished;

  extern "C" void task1(long int, long int, long int, long int, long int, long int, long int, long int, long int, long int)
  {
	assert(1);
	taskDelay(30);	
	assert(2);
	finished = true;
  }

#endif

/**
 *  Main functions
 */
#if defined(PLAT_VXWORKS) || defined(_WRS_VXWORKS_MAJOR)
  extern "C" int tSysMain(const char* arg)
  {
    const char* argv[2];
    argv[0]  = "undefined";
    argv[1]  = arg;
    int argc = sizeof(argv) / sizeof(char*);
#else

  int main(int argc, char *const argv[])
  {
#endif

#ifdef __SOLO__

    kernelInit(testTask, argc, argv);
    while(!finished) { sleep(1); }
    exit(0);
}

void testTask(long a1, long a2, long a3, long a4, long a5,
	long a6, long a7, long a8, long a9, long a10)
{
   int argc=0; char *const argv[]={0};
#endif

   // Initialisierung
   SEM_ID testBSem1 = semBCreate (0, SEM_EMPTY);

   assert(semTake(testBSem1, 10) == ERROR);  // Empty
   assert(semGive(testBSem1) == OK);
   assert(semGive(testBSem1) == OK);    // wie VxWorks

  printf("%s done\n", __FUNCTION__);
#ifdef __SOLO__
  finished = true;
  return;
#else
  return 0;
#endif
}


//  ___________________________________________________________________________

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Xenomai-core] xenomai-solo-vxWorks: Calling semGive twice on a binary semaphore should not return an error
  2008-09-21 20:26 [Xenomai-core] xenomai-solo-vxWorks: Calling semGive twice on a binary semaphore should not return an error Niklaus Giger
@ 2008-09-22 14:49 ` Philippe Gerum
  2008-09-22 17:59   ` Niklaus Giger
  0 siblings, 1 reply; 3+ messages in thread
From: Philippe Gerum @ 2008-09-22 14:49 UTC (permalink / raw)
  To: Niklaus Giger; +Cc: xenomai-core

Niklaus Giger wrote:
> Hi
> 
> Examining errors in my big testsuite I discovered that giving a second
> time a binary semaphore xenomai returns an error where vxWorks reports OK.
> 

Thanks for reporting. That patch should fix this issue:

diff --git a/vxworks/semLib.c b/vxworks/semLib.c
index 62f9326..6467354 100644
--- a/vxworks/semLib.c
+++ b/vxworks/semLib.c
@@ -104,8 +104,11 @@ static STATUS xsem_give(struct wind_sem *sem)
 	if (syncobj_lock(&sem->u.xsem.sobj, &syns))
 		return S_objLib_OBJ_ID_ERROR;

-	if (sem->u.xsem.value >= sem->u.xsem.maxvalue)
-		ret = S_semLib_INVALID_OPERATION;
+	if (sem->u.xsem.value >= sem->u.xsem.maxvalue) {
+		if (sem->u.xsem.maxvalue == INT_MAX)
+			/* No wrap around. */
+			ret = S_semLib_INVALID_OPERATION;
+	}
 	else if (++sem->u.xsem.value <= 0)
 		syncobj_post(&sem->u.xsem.sobj);

> See the attached test case.
>> sudo  ../../bin/BSys/mak/xeno_vx-solo/debug/tst
>> assert passed at testTask line 65
>> assert passed at testTask line 66
>> assert failed at testTask line 67
>> testTask done
>> Xenomai/SOLO: failed to remove registry mount point /mnt/xenomai/4569
>> (errno=16)
> 
> Best regards
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Xenomai-core mailing list
> Xenomai-core@domain.hid
> https://mail.gna.org/listinfo/xenomai-core


-- 
Philippe.



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Xenomai-core] xenomai-solo-vxWorks: Calling semGive twice on a binary semaphore should not return an error
  2008-09-22 14:49 ` Philippe Gerum
@ 2008-09-22 17:59   ` Niklaus Giger
  0 siblings, 0 replies; 3+ messages in thread
From: Niklaus Giger @ 2008-09-22 17:59 UTC (permalink / raw)
  To: rpm; +Cc: xenomai-core

Hi 

Thanks a lot. This patch does indeed fix my problem.

Best regards

Niklaus
Am Montag 22 September 2008 16.49:01 schrieb Philippe Gerum:
> Niklaus Giger wrote:
> > Hi
> >
> > Examining errors in my big testsuite I discovered that giving a second
> > time a binary semaphore xenomai returns an error where vxWorks reports
> > OK.
>
> Thanks for reporting. That patch should fix this issue:
>
> diff --git a/vxworks/semLib.c b/vxworks/semLib.c
> index 62f9326..6467354 100644
> --- a/vxworks/semLib.c
> +++ b/vxworks/semLib.c
> @@ -104,8 +104,11 @@ static STATUS xsem_give(struct wind_sem *sem)
>  	if (syncobj_lock(&sem->u.xsem.sobj, &syns))
>  		return S_objLib_OBJ_ID_ERROR;
>
> -	if (sem->u.xsem.value >= sem->u.xsem.maxvalue)
> -		ret = S_semLib_INVALID_OPERATION;
> +	if (sem->u.xsem.value >= sem->u.xsem.maxvalue) {
> +		if (sem->u.xsem.maxvalue == INT_MAX)
> +			/* No wrap around. */
> +			ret = S_semLib_INVALID_OPERATION;
> +	}
>  	else if (++sem->u.xsem.value <= 0)
>  		syncobj_post(&sem->u.xsem.sobj);
>
> > See the attached test case.
> >
> >> sudo  ../../bin/BSys/mak/xeno_vx-solo/debug/tst
> >> assert passed at testTask line 65
> >> assert passed at testTask line 66
> >> assert failed at testTask line 67
> >> testTask done
> >> Xenomai/SOLO: failed to remove registry mount point /mnt/xenomai/4569
> >> (errno=16)
> >
> > Best regards
> >
> >
> >
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > Xenomai-core mailing list
> > Xenomai-core@domain.hid
> > https://mail.gna.org/listinfo/xenomai-core

-- 
NIklaus Giger



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-09-22 17:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-21 20:26 [Xenomai-core] xenomai-solo-vxWorks: Calling semGive twice on a binary semaphore should not return an error Niklaus Giger
2008-09-22 14:49 ` Philippe Gerum
2008-09-22 17:59   ` Niklaus Giger

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.