All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai-help] pthread_setschedparam() segfault using Xenomai 2.5.2
@ 2010-05-26 15:23 Stephen Bryant
  2010-05-26 15:33 ` Gilles Chanteperdrix
  0 siblings, 1 reply; 5+ messages in thread
From: Stephen Bryant @ 2010-05-26 15:23 UTC (permalink / raw)
  To: xenomai


[-- Attachment #1.1: Type: text/plain, Size: 754 bytes --]

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

[-- Attachment #1.2: Type: text/html, Size: 815 bytes --]

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

#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");
}

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

end of thread, other threads:[~2010-05-26 16:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-26 15:23 [Xenomai-help] pthread_setschedparam() segfault using Xenomai 2.5.2 Stephen Bryant
2010-05-26 15:33 ` Gilles Chanteperdrix
2010-05-26 15:35   ` Stephen Bryant
     [not found]   ` <AANLkTik4hSCdh03zRoiqLGfaF3RftwzhuWz-Qbfo7BDv@domain.hid>
     [not found]     ` <4BFD400F.1080307@domain.hid>
2010-05-26 16:08       ` Stephen Bryant
2010-05-26 16:22         ` Gilles Chanteperdrix

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.