Hi,
I am receiving a segfault when calling pthread_setschedparam(). Both the
thread and the scheduling parameters are initialised to appropraite values,
and I am using SCHED_FIFO. Attached is example code, similar to my
application (rather than minimalist), that reproduces the error when
compiled for Xenomai (with '--skin=posix --ldflags' and '--cflags'), while
running cleanly when compiled for standard linux.
Is this a problem with pthread_setschedparam(), or am I doing something
wrong? If you need any more information then let me know.
I am running:
Linux kernel 2.6.32.8
Adeos patch adeos-ipipe-2.6.32.7-x86-2.6-01.patch (it patched cleanly onto
2.6.32.8)
Xenomai 2.5.2
Processor: Core 2 Duo (kernel is compiled to use only 1 core)
Steve
#ifdef __XENO__
#include <posix/posix.h>
#include <sys/mman.h>
#else
#include <pthread.h>
#endif // __XENO__
#include <stdio.h>
#include <unistd.h>
typedef void* (*ENTRYPOINT)(void*);
struct ThreadArgs
{
public:
ENTRYPOINT pFcn;
void* pFcnArgs;
int Priority;
};
void *ThreadWrapper(void *pArgs);
void TestFcn();
int main()
{
#ifdef __XENO__
mlockall(MCL_CURRENT | MCL_FUTURE);
#endif //__XENO__
pthread_t* pThread = new pthread_t();;
struct ThreadArgs *pTArgs = new struct ThreadArgs;
pthread_attr_t ThreadCustomAttr;
pthread_attr_init(&ThreadCustomAttr);
#ifdef __XENO__
pthread_attr_setstacksize(&ThreadCustomAttr, PTHREAD_STACK_MIN + 10000);
#else
pthread_attr_setstacksize(&ThreadCustomAttr, 20000);
#endif // __XENO__
pthread_attr_setdetachstate(&ThreadCustomAttr, PTHREAD_CREATE_DETACHED);
pthread_attr_setinheritsched(&ThreadCustomAttr, PTHREAD_EXPLICIT_SCHED);
pthread_attr_setscope(&ThreadCustomAttr, PTHREAD_SCOPE_PROCESS);
pTArgs->pFcn = (ENTRYPOINT) TestFcn;
pTArgs->pFcnArgs = NULL;
pTArgs->Priority = 60;
pthread_create(pThread, &ThreadCustomAttr, ThreadWrapper, (void *) pTArgs);
if(pThread != NULL) { delete pThread; }
sleep(3);
return 0;
}
void *ThreadWrapper(void *pArgs)
{
void *pResult;
struct ThreadArgs *pTArgs = (struct ThreadArgs *) pArgs;
struct sched_param SchedParam;
SchedParam.sched_priority = pTArgs->Priority;
pthread_setschedparam(pthread_self(), SCHED_FIFO, &SchedParam);
pResult = (void *) pTArgs->pFcn(pTArgs->pFcnArgs);
delete pTArgs;
return pResult;
}
void TestFcn()
{
printf("Made it\n");
}
_______________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help