xenomai-solo-vxWorks: Calling semGive twice on a binary semaphore should not return an error
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.
Quoted 7 lines
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
Signature · 1 line
NIklaus Giger
#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
}
// ___________________________________________________________________________
Quoted 5 lines · Niklaus Giger
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:
vxworks/semLib.c +5 -2
@@ -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);
Quoted 19 lines
See the attached test case.
Quoted 7 lines
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
[email protected]
https://mail.gna.org/listinfo/xenomai-core
Signature · 1 line
Philippe.
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:
Quoted 47 lines
Quoted 5 lines · Niklaus Giger
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:
vxworks/semLib.c +5
-2@@ -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);Quoted 20 lines
See the attached test case.
Quoted 7 lines
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
[email protected]
https://mail.gna.org/listinfo/xenomai-core
Signature · 1 line
NIklaus Giger