2010-11-29 07:08:30     Posix Timer using Thread - timer_create

Document created by Aaronwu Employee on Oct 16, 2013
Version 1Show Document
  • View in full screen mode

2010-11-29 07:08:30     Posix Timer using Thread - timer_create

Jeremie RAFIN (FRANCE)

Message: 96287   

 

Hello,

 

 

 

I am trying to create a posix timer with a "pthread callback". Something like that (so far I am blocking on creation, so I just give you this part):

 

#include <signal.h>

#include <time.h>

#include <stdio.h>

#include <errno.h>

 

static void TimerCallBack(union sigval sigev_value)

{

  printf("Hello\n");

}

 

int main(void)

{

  struct sigevent     SignalEventManagement;

  timer_t             TimerId;

 

  /* Set signal event management */

  SignalEventManagement.sigev_notify            = SIGEV_THREAD;       /* Notification method: POSIX THREAD              */

  SignalEventManagement.sigev_value.sival_ptr   = &TimerId;           /* Value passed to thread function: timer handler */

  SignalEventManagement.sigev_notify_function   = TimerCallBack;      /* Function used for notifications                */

 

  /* Create a kernel timer */

  if (timer_create(/* ClockId  */ CLOCK_REALTIME,

                   /* SigEvent */ &SignalEventManagement,

                   /* TimerId  */ &TimerId) != 0)

  {

    printf("Error %d\n", errno);

    return -1;

  }

 

  return 0;

}

 

 

My problem is that I get error, with errno set to zero. [BTW, please note that this is not "posix" since errno should be set.]

 

After investigating the implementation of the timer_create in the toolchain, it appears that SIGEV_THREAD is not supported.

 

Is there any needed patch for toolchain to have posix timer fully implemented (I have 2009R1 one)?

 

Any other way to have posix timer?

 

 

 

Thanks for you help!

 

Best regards,

 

Jeremie

Attachments

    Outcomes